Exemplo n.º 1
0
void ActionEllipse::update(float dt)
{  //t [0, 1]
	
	if (_target){
		float x = getEllipsePositionX(dt);
		float y = getEllipsePositionY(dt);
		Point newPosition = _config.center + Point(x, y);
		//由于我们画计算出的椭圆你做值是以原点为中心的,所以需要加上我们设定的中心点坐标
		_target->setPosition(_config.center + Point(x, y));

		if (dt <= 0.5){
			_target->setLocalZOrder(_config.zOrder.first);
		}
		else{
			_target->setLocalZOrder(_config.zOrder.second);
		}

#if 0
		CCDrawNode *node = CCDrawNode::create();
		node->drawDot(newPosition, 0.5f, ccc4f(17, 128,18, 60));
		_target->getParent()->addChild(node);
#endif

	}



}
Exemplo n.º 2
0
void ScrollViewDemo::setup()
{
    CCClippingNode *clipper = CCClippingNode::create();
    clipper->setTag( kTagClipperNode );
    clipper->setContentSize(  CCSizeMake(200, 200) );
    clipper->setAnchorPoint(  ccp(0.5, 0.5) );
    clipper->setPosition( ccp(this->getContentSize().width / 2, this->getContentSize().height / 2) );
    clipper->runAction(CCRepeatForever::create(CCRotateBy::create(1, 45)));
    this->addChild(clipper);

    CCDrawNode *stencil = CCDrawNode::create();
    CCPoint rectangle[4];
    rectangle[0] = ccp(0, 0);
    rectangle[1] = ccp(clipper->getContentSize().width, 0);
    rectangle[2] = ccp(clipper->getContentSize().width, clipper->getContentSize().height);
    rectangle[3] = ccp(0, clipper->getContentSize().height);
    
    ccColor4F white = {1, 1, 1, 1};
    stencil->drawPolygon(rectangle, 4, white, 1, white);
    clipper->setStencil(stencil);

    CCSprite *content = CCSprite::create(s_back2);
    content->setTag( kTagContentNode );
    content->setAnchorPoint(  ccp(0.5, 0.5) );
    content->setPosition( ccp(clipper->getContentSize().width / 2, clipper->getContentSize().height / 2) );
    clipper->addChild(content);
    
    m_bScrolling = false;

    this->setTouchEnabled(true);
}
Exemplo n.º 3
0
bool CardBase::ccTouchBegan(CCTouch* touch, CCEvent* event)
{
	glLineWidth(16);
	ccDrawColor4B(255,0,0,255);
	CCPoint vertices[] = { ccp(0, 0), ccp(50, 50), ccp(100, 50), ccp(100, 100) };
	ccDrawPoly(vertices, 4, true);

	//glLineWidth(16);
	//ccDrawColor4B(0, 255, 0, 255);
	//ccDrawCircle( VisibleRect::center(), 100, 0, 10, false);
	CCSize s = this->backGround->getContentSize();

	CCDrawNode *draw = CCDrawNode::create();
	addChild(draw, 10);

	// Draw polygons
	CCPoint points[] = { CCPoint(s.height/4,0), CCPoint(s.width,s.height/5), CCPoint(s.width/3*2,s.height) };
	draw->drawPolygon(points, sizeof(points)/sizeof(points[0]), ccc4f(1,0,0,0.5), 0, ccc4f(0,0,0,0));

	// Draw segment
	//draw->drawSegment(ccp(20,s.height), ccp(20,s.height/2), 10, ccc4f(0, 1, 0, 0.5));

	//draw->drawSegment(ccp(10,s.height/2), ccp(s.width/2, s.height/2), 40, ccc4f(1, 0, 1, 0.5));

//	this->addChild(shadow);
//	addChild(shadow);

	CCLog("ccTouchBegan");
	return true;
}
Exemplo n.º 4
0
void CCClipOut::update(float time) {
    CCClippingNode* clipper = (CCClippingNode*)getTarget();
    CCDrawNode* stencil = (CCDrawNode*)clipper->getStencil();
    
    // clear
    stencil->clear();
    
    // build polygon
    float distance = m_distance * (1 - time);
    if(distance < FLT_EPSILON) {
        CCPoint v[] = {
            CCPointZero,
            CCPointZero,
            CCPointZero,
            CCPointZero
        };
        stencil->drawPolygon(v, 4, cc4fGREEN, 0, cc4fTRANSPARENT);
    } else {
        CCPoint v[] = {
            m_p1,
            m_p2,
            ccp(m_p2.x + distance * m_cos,
                m_p2.y + distance * m_sin),
            ccp(m_p1.x + distance * m_cos,
                m_p1.y + distance * m_sin)
        };
        stencil->drawPolygon(v, 4, cc4fGREEN, 0, cc4fTRANSPARENT);
    }
}
Exemplo n.º 5
0
bool Background::Init()
{
    do
    {
        CCNodeLoaderLibrary * ccNodeLoaderLibraryLeft = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary();
        CCBReader * ccbReaderLeft = new CCBReader(ccNodeLoaderLibraryLeft);
        CCNode * bgLeft = ccbReaderLeft->readNodeGraphFromFile("ccb/background.ccbi", this);
        CCBAnimationManager* animationManagerLeft = ccbReaderLeft->getAnimationManager();
        animationManagerLeft->runAnimationsForSequenceNamed("left");
        ccbReaderLeft->release();
        
        CCNodeLoaderLibrary * ccNodeLoaderLibraryRight = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary();
        CCBReader * ccbReaderRight = new CCBReader(ccNodeLoaderLibraryRight);
        CCNode * bgRight = ccbReaderRight->readNodeGraphFromFile("ccb/background.ccbi", this);
        CCBAnimationManager* animationManagerRight = ccbReaderRight->getAnimationManager();
        animationManagerRight->runAnimationsForSequenceNamed("right");
        ccbReaderRight->release();
        
        CCClippingNode * clippingNodeLeft = CCClippingNode::create();
        addChild(clippingNodeLeft);
        clippingNodeLeft->addChild(bgLeft,enZOrderBack,enTagBgLeft);
        CCDrawNode *shapeLeft = CCDrawNode::create();
        static CCPoint triangleLeft[3];
        triangleLeft[0] = ccp(0, 0);
        triangleLeft[1] = ccp(SCREEN_WIDTH,0);
        triangleLeft[2] = ccp(0,SCREEN_HEIGHT);
        static ccColor4F green = {0, 1, 0, 1};
        shapeLeft->drawPolygon(triangleLeft, 3, green, 0, green);
        clippingNodeLeft->setStencil(shapeLeft);
        clippingNodeLeft->setInverted(false);
        
        CCClippingNode * clippingNodeRight = CCClippingNode::create();
        addChild(clippingNodeRight);
        clippingNodeRight->addChild(bgRight,enZOrderBack,enTagBgRight);
        CCDrawNode *shapeRight = CCDrawNode::create();
        static CCPoint triangleRight[3];
        triangleRight[0] = ccp(SCREEN_WIDTH, SCREEN_HEIGHT);
        triangleRight[1] = ccp(SCREEN_WIDTH,0);
        triangleRight[2] = ccp(0,SCREEN_HEIGHT);
//        static ccColor4F green = {0, 1, 0, 1};
        shapeRight->drawPolygon(triangleRight, 3, green, 0, green);
        clippingNodeRight->setStencil(shapeRight);
        clippingNodeRight->setInverted(false);
        
        m_CraterArrayLeft = CCArray::create();
        m_CraterArrayLeft->retain();
        m_CraterArrayRight = CCArray::create();
        m_CraterArrayRight->retain();
        m_CraterArrayLeftDeleted = CCArray::create();
        m_CraterArrayLeftDeleted->retain();
        m_CraterArrayRightDeleted = CCArray::create();
        m_CraterArrayRightDeleted->retain();
        
        
        return true;
    } while (false);
    CCLog("Function Background::Init Error!");
    return false;
}
Exemplo n.º 6
0
GameStage::~GameStage(void)
{
	this->background->removeFromParent();
	this->floorBg->removeFromParent();
	this->floorLineBg->removeFromParent();
	this->hand->removeFromParent();
	this->body->removeFromParent();
	this->uiText->removeFromParent();
	this->uiLayer->removeFromParent();

	CC_SAFE_RELEASE(this->uiText);
	CC_SAFE_RELEASE(this->uiLayer);
	CC_SAFE_RELEASE(this->body);
	CC_SAFE_RELEASE(this->hand);
	CC_SAFE_RELEASE(this->background);
	CC_SAFE_RELEASE(this->floorBg);
	CC_SAFE_RELEASE(this->floorLineBg);

	if(this->bomb)
	{
		this->bomb->removeFromParent();
		this->bomb->stopSystem();
	}
	CC_SAFE_RELEASE(this->bomb);

	//删除数组
	this->removeList(this->comboList);
	this->removeList(this->scoreList);
	this->removeList(this->highScoreList);
	this->removeList(this->addScoreList);
	this->addScoreSpt->stopAllActions();
	this->newHighScore->stopAllActions();
	this->addScoreSpt->removeFromParent();
	this->newHighScore->removeFromParent();
	CC_SAFE_RELEASE(this->addScoreSpt);
	CC_SAFE_RELEASE(this->newHighScore);

	int length = this->drawBgList->count();
	CCDrawNode* dn;
	for (int i = length -1 ; i >= 0; i-=1)
	{
		dn = static_cast<CCDrawNode *>(this->drawBgList->objectAtIndex(i));
		dn->removeFromParent();
		this->drawBgList->removeObject(dn);
	}
	CC_SAFE_RELEASE(this->drawBgList);

	length = this->frontBgList->count();
	for (int i = length -1 ; i >= 0; i-=1)
	{
		dn = static_cast<CCDrawNode *>(this->frontBgList->objectAtIndex(i));
		dn->removeFromParent();
		this->frontBgList->removeObject(dn);
	}
	CC_SAFE_RELEASE(this->frontBgList);
}
Exemplo n.º 7
0
void GameLogic_init::clip(CCClippingNode* clipping, cocos2d::CCPoint _center, float wh){
    CCDrawNode *stencil = (CCDrawNode*)clipping->getStencil();
    CCPoint rectangle[4];
    rectangle[0] = ccp(_center.x-wh/2, _center.y-wh/2);
    rectangle[1] = ccp(_center.x+wh/2, _center.y-wh/2);
    rectangle[2] = ccp(_center.x+wh/2,_center.y+wh/2);
    rectangle[3] = ccp(_center.x-wh/2, _center.y+wh/2);
    ccColor4F white = {0, 0, 0, 1};
    stencil->drawPolygon(rectangle, 4, white, 1, white);
}
Exemplo n.º 8
0
CCDrawNode* BasicTest::shape()
{
    CCDrawNode *shape = CCDrawNode::create();
    static CCPoint triangle[3];
    triangle[0] = ccp(-100, -100);
    triangle[1] = ccp(100, -100);
    triangle[2] = ccp(0, 100);

    static ccColor4F green = {0, 1, 0, 1};
    shape->drawPolygon(triangle, 3, green, 0, green);
    return shape;
}
Exemplo n.º 9
0
CCDrawNode* createPentNode( ccColor4F fill, ccColor4F outline)
{
	CCPoint pent[5];
	pent[0] = CCPointMake(0,10);
	pent[1] = CCPointMake(10,2);
	pent[2] = CCPointMake(5,-7);
	pent[3] = CCPointMake(-5,-7);
	pent[4] = CCPointMake(-10,2);

	CCDrawNode* pt = CCDrawNode::create();
	pt->drawPolygon(pent, 5, fill, 1, outline);
	return pt;
}
Exemplo n.º 10
0
CCDrawNode* CCDrawNode::create()
{
    CCDrawNode* pRet = new CCDrawNode();
    if (pRet && pRet->init())
    {
        pRet->autorelease();
    }
    else
    {
        CC_SAFE_DELETE(pRet);
    }
    
    return pRet;
}
Exemplo n.º 11
0
    virtual bool init()
    {
        if ( CCNode::init() == false ) {
            return false;
        }
        
        objSize_    = CCSizeMake(120, 120);

        CCDrawNode* pTestDraw   = CCDrawNode::create();
        pTestDraw->drawDot(ccp(0,0), objSize_.width * 0.5f, ccc4FFromccc4B(ccc4(128, 0, 0, 230)));
        
        addChild(pTestDraw);
        
        return true;
    }
Exemplo n.º 12
0
    virtual bool init()
    {
        if ( CCNode::init() == false ) {
            return false;
        }
        
        objSize_    = CCSizeMake(60, 60);

        //  テスト描画用
        {
            CCDrawNode* pTestDraw  = CCDrawNode::create();
            pTestDraw->drawDot(ccp(0,0), objSize_.width * 0.5f, ccc4FFromccc4B(ccc4(255, 255, 255, 128)));
            addChild(pTestDraw);
        }

        return true;
    }
Exemplo n.º 13
0
/*判断跳跃范围,只有在有背景的范围下才能跳跃*/
bool GameStage::inWallBoundaries()
{
	CCDrawNode* drawNode;
	int length = this->frontBgList->count();
	float left;
	float right;
	for (int i = length - 1; i >= 0; i-=1)
	{
		drawNode = static_cast<CCDrawNode *>(this->frontBgList->objectAtIndex(i));
		left = drawNode->getPositionX() - this->pukaManCore->roleVo->width * .5;
		right = left + drawNode->getContentSize().width + this->pukaManCore->roleVo->width * .5;
		if(this->pukaManCore->roleVo->x >= left && 
			this->pukaManCore->roleVo->x <= right)
			return true;
	}
	return false;
}
Exemplo n.º 14
0
void CCClipIn::update(float time) {
    CCClippingNode* clipper = (CCClippingNode*)getTarget();
    CCDrawNode* stencil = (CCDrawNode*)clipper->getStencil();
    
    // clear
    stencil->clear();
    
    // build polygon
    float distance = m_distance * time;
    CCPoint v[] = {
        m_p1,
        m_p2,
        ccp(m_p2.x + distance * m_cos,
            m_p2.y + distance * m_sin),
        ccp(m_p1.x + distance * m_cos,
            m_p1.y + distance * m_sin)
    };
    stencil->drawPolygon(v, 4, cc4fGREEN, 0, cc4fTRANSPARENT);
}
Exemplo n.º 15
0
/*创建运动背景*/
CCDrawNode* GameStage::createMotionWall(float x, float y, 
									  float bgWidth, float bgHeight, 
									  float gapH, ccColor4F color)
{
	int num = (int)(this->stageWidth / (bgWidth + gapH));
	CCDrawNode* drawNode = CCDrawNode::create();
	for (int i = 0; i < num; i+=1)
	{
		int startX = i * (bgWidth + gapH) + x;
		CCPoint points[] = {CCPoint(startX, y), 
							CCPoint(startX, bgHeight + y), 
							CCPoint(startX + bgWidth, bgHeight + y), 
							CCPoint(startX + bgWidth, y)};
		//顶点列表,顶点数量,颜色
		drawNode->drawPolygon(points, 4, color, 0, ColorUtil::getColor4F(0, 0, 0, 0));
	}
	//如果不设置宽高则 始终为0,即使内部有复杂的绘图。
	drawNode->setContentSize(CCSizeMake(num * (bgWidth + gapH), bgHeight));
	return drawNode;
}
Exemplo n.º 16
0
bool BackgroundManager::init()
{
	if ( !CCNode::init() )
    {
        return false;
    }

	setContentSize(CCSizeMake(SCREEN_SIZE.width * 1.2f, SCREEN_SIZE.height * 1.2f));

	CCDrawNode* star = CCDrawNode::create();
	addChild(star);

	for(int i = 0; i < MAX_STARS; ++i)
	{
		CCPoint position = ccp(CCRANDOM_0_1() * SCREEN_SIZE.width * 1.2f, CCRANDOM_0_1() * SCREEN_SIZE.height * 1.2f);
		float alpha = 0.25f + CCRANDOM_0_1() * 0.75f;
		star->drawDot(position, 1, ccc4f(1, 1, 1, alpha));
	}

	return true;
}
Exemplo n.º 17
0
MathUtilTest::MathUtilTest(void)
{

	CCPoint a = ccp(339.95, 117.1);
	CCPoint b = ccp(411.15, 190.1);
	CCPoint c = ccp(325.05, 273.8);
	CCPoint d = ccp(253.95, 200.7);
	CCPoint p = ccp(310, 250);

	CCDrawNode* node = CCDrawNode::create();
	node->drawDot(a, 5, ColorUtil::getColor4F(0xFF, 0x00, 0x00, 0xFF));
	node->drawDot(b, 5, ColorUtil::getColor4F(0xFF, 0x00, 0x00, 0xFF));
	node->drawDot(c, 5, ColorUtil::getColor4F(0xFF, 0x00, 0x00, 0xFF));
	node->drawDot(d, 5, ColorUtil::getColor4F(0xFF, 0x00, 0x00, 0xFF));
	node->drawDot(p, 5, ColorUtil::getColor4F(0xFF, 0xCC, 0x00, 0xFF));

	this->addChild(node);

	//CCLOG("%d", MathUtil::isInsideTriangle(a, b, c, p));
	CCLOG("%d", MathUtil::isInsideSquare(a, b, c, d, p));

}
Exemplo n.º 18
0
// DrawNodeTest
DrawNodeTest::DrawNodeTest()
{
    CCSize s = CCDirector::sharedDirector()->getWinSize();
    
    CCDrawNode *draw = CCDrawNode::create();
    addChild(draw, 10);
    
    // Draw 10 circles
    for( int i=0; i < 10; i++)
    {
        draw->drawDot(ccp(s.width/2, s.height/2), 10*(10-i), ccc4f(CCRAScutOM_0_1(), CCRAScutOM_0_1(), CCRAScutOM_0_1(), 1));
    }
    
    // Draw polygons
    CCPoint points[] = { CCPoint(s.height/4,0), CCPoint(s.width,s.height/5), CCPoint(s.width/3*2,s.height) };
    draw->drawPolygon(points, sizeof(points)/sizeof(points[0]), ccc4f(1,0,0,0.5), 4, ccc4f(0,0,1,1));
    
    // star poly (triggers buggs)
    {
        const float o=80;
        const float w=20;
        const float h=50;
        CCPoint star[] = {
            CCPoint(o+w,o-h), CCPoint(o+w*2, o),						// lower spike
            CCPoint(o + w*2 + h, o+w ), CCPoint(o + w*2, o+w*2),		// right spike
            //				{o +w, o+w*2+h}, {o,o+w*2},					// top spike
            //				{o -h, o+w}, {o,o},							// left spike
        };
        
        draw->drawPolygon(star, sizeof(star)/sizeof(star[0]), ccc4f(1,0,0,0.5), 1, ccc4f(0,0,1,1));
    }
    
    // star poly (doesn't trigger bug... order is important un tesselation is supported.
    {
        const float o=180;
        const float w=20;
        const float h=50;
        CCPoint star[] = {
            CCPoint(o,o), CCPoint(o+w,o-h), CCPoint(o+w*2, o),		// lower spike
            CCPoint(o + w*2 + h, o+w ), CCPoint(o + w*2, o+w*2),	// right spike
            CCPoint(o +w, o+w*2+h), CCPoint(o,o+w*2),				// top spike
            CCPoint(o -h, o+w),                                     // left spike
        };
        
        draw->drawPolygon(star, sizeof(star)/sizeof(star[0]), ccc4f(1,0,0,0.5), 1, ccc4f(0,0,1,1));
    }
    
    
    // Draw segment
    draw->drawSegment(ccp(20,s.height), ccp(20,s.height/2), 10, ccc4f(0, 1, 0, 1));

    draw->drawSegment(ccp(10,s.height/2), ccp(s.width/2, s.height/2), 40, ccc4f(1, 0, 1, 0.5));
}
Exemplo n.º 19
0
void SpellDiagramNode::addMod( int idx, float x, float y, int level ) {

	if( idx < m_modSlots.size() )
	{
		CCDrawNode* pt = m_modSlots[idx];
		pt->runAction( CCMoveTo::create(TRANSITION_TIME, ccp(x,y)) );
	}else {

		CCDrawNode* pt = createPentNode(MOD_COLOR, ccc4f(0,0,0,1));
		pt->setPosition(x,y);
		addChild(pt);
		pt->setScale(0.01f);
		pt->runAction(CCScaleTo::create(TRANSITION_TIME/2, 1,1));
		m_modSlots.push_back(pt);
	}
}
Exemplo n.º 20
0
void UiEditorPanel::drawFrame()
{
	CCSize size = CCSize(1000, 800);

	CCPoint leftBottom(0, 0);
	CCPoint leftTop(0, size.height);
	CCPoint rightBottom(size.width, 0);
	CCPoint rightTop(size.width, size.height);

	CCDrawNode *drawNode = CCDrawNode::create();
	addChild(drawNode);

	drawNode->drawSegment(leftBottom, rightBottom, 0.5f, ccc4f(0.5f, 0.5f, 0.5f, 1));
	drawNode->drawSegment(rightBottom, rightTop, 0.5f, ccc4f(0.5f, 0.5f, 0.5f, 1));
	drawNode->drawSegment(rightTop, leftTop, 0.5f, ccc4f(0.5f, 0.5f, 0.5f, 1));
	drawNode->drawSegment(leftTop, leftBottom, 0.5f, ccc4f(0.5f, 0.5f, 0.5f, 1));

	auto winSize = CCDirector::sharedDirector()->getWinSize();
	auto offset = ccp((winSize.width - size.width) * 0.5f, (winSize.height - size.height) * 0.5f);
	drawNode->setPosition(offset);
}
Exemplo n.º 21
0
void GameStage::onEnter()
{
	CCLOG("gamestage onEnter");
	this->stageWidth = 640;
	this->stageHeight = 360;
	//监听失败消息
	CCNotificationCenter::sharedNotificationCenter()->addObserver(
		this,                         
		callfuncO_selector(GameStage::failCallBackFun),  // 处理的消息的回调函数
		FAIL,  // 感兴趣的消息名称
		NULL);   

	//背景
	ccColor4B color4b;
	color4b.r = 42;
	color4b.g = 43;
	color4b.b = 38;
	color4b.a = 0xFF;
	this->background = CCLayerColor::create(color4b);
	this->addChild(this->background);

	//运动背景
	float bgWidth = 43;
	float bgHeigth = this->stageHeight - 140;
	float gapH = 10;
	//使这个数组已经是当前类的成员变量,也必须要做一次retain
	this->drawBgList = CCArray::create();
	this->drawBgList->retain();

	ccColor4F color4f = ColorUtil::getColor4F(56, 57, 51, 255);

	CCDrawNode* drawNode = this->createMotionWall(0, 140, bgWidth, bgHeigth, gapH, color4f);
	float posX = drawNode->getContentSize().width;
	this->drawBgList->addObject(drawNode);
	this->addChild(drawNode);

	drawNode = this->createMotionWall(0, 140, bgWidth, bgHeigth, gapH, color4f);
	drawNode->setPosition(ccp(posX, 0));
	this->drawBgList->addObject(drawNode);
	this->addChild(drawNode);

	//地板
	color4b.r = 116;
	color4b.g = 115;
	color4b.b = 98;
	color4b.a = 0xFF;
	this->floorBg = CCLayerColor::create(color4b);

	CCSize size = CCSizeMake(this->stageWidth, 141);
	this->floorBg->setContentSize(size);
	this->addChild(this->floorBg);
	//地板线条
	color4b.r = 72;
	color4b.g = 66;
	color4b.b = 50;
	color4b.a = 0xFF;
	this->floorLineBg = CCLayerColor::create(color4b);
	size = CCSizeMake(this->stageWidth, 10);
	this->floorLineBg->setContentSize(size);
	this->addChild(this->floorLineBg);
	this->floorLineBg->setPosition(ccp(0, this->floorBg->getContentSize().height));

	//前景
	this->frontBgList = CCArray::create();
	this->frontBgList->retain();

	for (int i = 0; i < 3; i++)
	{
		drawNode = this->createFrontMotionWall(0, 83, this->stageWidth, this->stageHeight - 83, i);
		this->addChild(drawNode);
		drawNode->setPosition(ccp(this->stageWidth * (i - 1), 0));
		this->frontBgList->addObject(drawNode);
	}

	//初始化核心类
	this->pukaManCore = new PukaManCore();
	this->pukaManCore->initGame(17, 2, 10, 15, 0.3, 0, CCDirector::sharedDirector()->getWinSize().height - 35, 70);
	/*初始化人物*/
	this->initRole(this->pukaManCore->roleVo->x, this->pukaManCore->roleVo->y);

	this->uiLayer = CCLayer::create();
	this->uiText = CCSprite::create("uiText.png");
	this->uiText->setAnchorPoint(ccp(0, 0));
	this->uiText->setPosition(ccp(0, this->stageHeight - 50));
	this->uiLayer->addChild(this->uiText);
	this->addChild(this->uiLayer);

	this->bomb = NULL;
	this->comboList = NULL;
	this->scoreList = NULL;
	this->highScoreList = NULL;
	
	//设置最高分记录
	if(Cookie::isSaved())
		this->pukaManCore->highScore = Cookie::getShareUserData()->getIntegerForKey("highScore");

	//设置bombo数字
	this->updateCombo();
	this->updateScore();
	//设置最高分数数字
	this->updateHighScore();
	this->layoutScoreNum(this->highScoreList, 2);

	this->addScoreSpt = CCSprite::create();
	this->addScoreList = CCArray::create();
	this->addScoreList->retain();
	this->updateNumSprite(this->addScoreSpt, 
							this->addScoreList, 
							this->pukaManCore->scoreVar, 0, 0);
	this->uiLayer->addChild(this->addScoreSpt);
	//加号
	CCSprite* addSpt = CCSprite::create("zAdd.png");
	addSpt->setAnchorPoint(ccp(0, 0));
	addSpt->setPosition(ccp(-addSpt->getContentSize().width * .5, 0));
	this->addScoreSpt->addChild(addSpt);
	this->addScoreList->insertObject(addSpt, 0);

	this->layoutScoreNum(this->addScoreList, 0);
	//父sprite执行颜色变化的时候,子sprite也可以执行到这个变化
	this->addScoreSpt->setCascadeOpacityEnabled(true);
	this->addScoreSpt->setVisible(false);

	this->newHighScore = CCSprite::create("newHighScore.png");
	this->newHighScore->setAnchorPoint(ccp(0.5f, 0.5f));
	this->newHighScore->setPosition(ccp(this->stageWidth * .5, this->stageHeight * .5));
	this->newHighScore->setScale(0.0f);
	this->uiLayer->addChild(this->newHighScore);
	//必须覆盖onEnter才能执行 loop监听
	CCScene::onEnter();
}
Exemplo n.º 22
0
bool ImageEditLayer::init(){
    if (DialogLayer::init()) {
        
        
        this->setTitle("头像编辑");
        
        CCPoint middle=ccp(286, 154);
        CCSize size=CCSizeMake(570,300);
        
        CCClippingNode* clippingNode = CCClippingNode::create();
        //设置裁剪区域大小
        clippingNode->setContentSize(size);
        clippingNode->setAnchorPoint(ccp(0.5, 0.5));
        clippingNode->setPosition(middle);
        m_contentLayer->addChild(clippingNode);
        
        CCTexture2D* textrue=new CCTexture2D();
        textrue->autorelease();
        textrue->initWithImage(_image);
        _sprite=CCSprite::createWithTexture(textrue);
        _initPoint=ccp(clippingNode->getContentSize().width/2, clippingNode->getContentSize().height/2);
        _sprite->setPosition(_initPoint);
        
        CCSize spriteSize=_sprite->getContentSize();
        if (size.width/spriteSize.width<size.height/spriteSize.height) {
            _scale=size.width/spriteSize.width;
        }else{
            _scale=size.height/spriteSize.height;
        }
        
        _sprite->setScale(_scale);
        clippingNode->addChild(_sprite);
        
        //创建裁剪模板,裁剪节点将按照这个模板来裁剪区域
        CCDrawNode *stencil = CCDrawNode::create();
        CCPoint rectangle[4];
        rectangle[0] = ccp(0, 0);
        rectangle[1] = ccp(clippingNode->getContentSize().width, 0);
        rectangle[2] = ccp(clippingNode->getContentSize().width, clippingNode->getContentSize().height);
        rectangle[3] = ccp(0, clippingNode->getContentSize().height);
        
        ccColor4F white = {1, 1, 1, 1};
        //画一个多边形 这画一个200x200的矩形作为模板
        stencil->drawPolygon(rectangle, 4, white, 1, white);
        clippingNode->setStencil(stencil);
        
        //用来设置显示裁剪区域还是非裁剪区域的
        clippingNode->setInverted(false);//在裁剪区域内显示加入的内容
        
        _clip=CCClippingNode::create();//创建裁剪节点,成员变量
        _clip->setInverted(true);//设置底板可见
        _clip->setAlphaThreshold(0.0f);//设置alpha为0
        m_contentLayer->addChild(_clip);//添加裁剪节点
        
        _mask=CCLayerColor::create(ccc4(0,0,0,160),size.width,size.height);
        CCPoint point=ccp(middle.x-size.width/2,middle.y-size.height/2);
        _mask->setPosition(point);
        _clip->addChild(_mask);//为裁剪节点添加一个黑色带透明(看起了是灰色)的底板
        
        _stencil=CCSprite::create("default_avatar.png");//使用头像原图作为模板
        _stencil->setPosition(middle);
        _stencil->setScale(STENCIL_SCALE);
        _clip->setStencil(_stencil);//设置模版
        
        CCSprite* queding=CCSprite::createWithSpriteFrameName("touxiang_queding.png");
        CCMenuItemSprite* item=CCMenuItemSprite::create(queding, queding, this, menu_selector(ImageEditLayer::menuCallback));
        item->setPosition(ccp(290,-30));//注意contentlayer坐标原点位置
        item->setScale(0.7);
        item->setTag(kTagConfirm);
        this->addMenuItem(item,true);
        
        CCSprite* fanhui=CCSprite::createWithSpriteFrameName("touxiang_fanhui.png");
        fanhui->setScale(0.87);
        CCMenuItemSprite* fanhuiItem=CCMenuItemSprite::create(fanhui, fanhui, this, menu_selector(ImageEditLayer::menuCallback));
        fanhuiItem->setPosition(ccp(19,368));
        fanhuiItem->setTag(kTagBack);
        this->addMenuItem(fanhuiItem,true);
        
        CCPoint contentPoint=m_contentLayer->getPosition();
        _rect=CCRectMake(contentPoint.x+point.x, contentPoint.y+point.y, size.width,size.height);
        
        return true;
    }
    return false;
}
Exemplo n.º 23
0
bool ResultScene::init()
{
    bool result = GradientLayer::init();

    if (result) {
        setTitle(MessageResultTitle);

        CCSize windowSize = CCDirector::sharedDirector()->getWinSize();
        GameEngine *engine = GameEngine::sharedEngine();

        CCSprite *braveImage = CCSprite::createWithSpriteFrameName("brave.png");
        braveImage->setRotation(90);
        braveImage->setPosition(ccp(windowSize.width / 2, windowSize.height - kBraveImageMarginTop - braveImage->getContentSize().height / 2));
        this->addChild(braveImage);

        CCLabelTTF *messageLabel = CCLabelTTF::create(engine->getResultMessage(), DefaultFontName, FontSizeSmall);
        messageLabel->setPosition(ccp(windowSize.width / 2 + kBraveMessageAdjustX, windowSize.height - kBraveMessageMarginTop));
        messageLabel->setAnchorPoint(ccp(0.0, 0.0));
        this->addChild(messageLabel);

        float boxBottom = kCommandAreaHeight + kCommandAreaMarginTop + kCommandAreaMarginBottom;
        CCDrawNode *boxNode = CCDrawNode::create();
        CCPoint contentBox[] = {ccp(kBoxMarginHorizontal, windowSize.height - kBoxMarginTop),
            ccp(windowSize.width - kBoxMarginHorizontal, windowSize.height - kBoxMarginTop),
            ccp(windowSize.width - kBoxMarginHorizontal, boxBottom),
            ccp(kBoxMarginHorizontal, boxBottom)};

        boxNode->drawPolygon(contentBox, 4, kBoxFillColor, 1, kBoxBorderColor);
        this->addChild(boxNode);

        CCString *scoreText = CCString::createWithFormat("%s:%d", MessageScoreText, engine->getScore());
        CCLabelTTF *scoreLabel = CCLabelTTF::create(scoreText->getCString(), DefaultFontName, FontSizeNormal);
        scoreLabel->setPosition(ccp(windowSize.width / 2, windowSize.height - kScoreLabelMarginTop));
        this->addChild(scoreLabel);

        map<hiberlite::sqlid_t, int> *foundItems = engine->getFoundItems();
        map<hiberlite::sqlid_t, int>::iterator foundItemsIterator = foundItems->begin();
        vector<Item> *items = engine->getItems();

        float itemImageAreaMarginLeft = windowSize.width / 2 - ((kNumberOfLineItems / 2 - 1) * (kItemImageSize + kItemImageMarginHorizontal)) - kItemImageMarginHorizontal / 2 - kItemImageSize / 2;

        int sumFoundItems = 0;
        int index = 0;
        while (foundItemsIterator != foundItems->end()) {
            hiberlite::sqlid_t itemID = (*foundItemsIterator).first;
            Item item = items->at(itemID - 1);
            int count = (*foundItemsIterator).second;

            const char *imageFileName = item->image.c_str();

            int posX = index % kNumberOfLineItems;
            int posY = index / kNumberOfLineItems;

            CCPoint imagePosition = ccp(itemImageAreaMarginLeft + (kItemImageSize + kItemImageMarginHorizontal) * posX,
                                        windowSize.height - kItemImageAreaMarginTop - (kItemImageSize + kItemImageMarginVertical) * posY);
            CCSprite *itemImage = CCSprite::createWithSpriteFrameName(imageFileName);
            itemImage->setPosition(imagePosition);
            this->addChild(itemImage);

            sumFoundItems += count;
            if (count > kItemCountMax) {
                count = kItemCountMax;
            }

            CCString *countText = CCString::createWithFormat("%d", count);
            CCLabelTTF *countLabel = CCLabelTTF::create(countText->getCString(), DefaultFontName, FontSizeSmall);
            countLabel->setPosition(ccpAdd(imagePosition, ccp(0, -kItemImageSize / 2 - kItemImageCountLabelAdjustY)));
            this->addChild(countLabel);

            foundItemsIterator++;
            index++;
        }

        CCString *itemCountText = CCString::createWithFormat("%s:%d", MessageNumberOfFoundItemsText, sumFoundItems);
        CCLabelTTF *itemCountLabel = CCLabelTTF::create(itemCountText->getCString(), DefaultFontName, FontSizeNormal);
        itemCountLabel->setPosition(ccp(windowSize.width / 2, windowSize.height - kItemCountLabelMarginTop));
        this->addChild(itemCountLabel);

        CCLayerColor *retryLayer = CCLayerColor::create((ccColor4B){0x00, 0x00, 0x00, 0x00}, kCommandButtonWidth, kCommandButtonHeight);
        CCLabelTTF *retryLabel = CCLabelTTF::create(MessageRetryButtonTitle, DefaultFontName, FontSizeNormal);
        retryLabel->setPosition(ccp(kCommandButtonWidth / 2, kCommandButtonHeight / 2));
        retryLayer->addChild(retryLabel);
        CCMenuItem *retryItem = CCMenuItemLabel::create(retryLayer,
                                                        GameEngine::sharedEngine(),
                                                        menu_selector(GameEngine::startNewGame));

        CCLayerColor *backTitleLayer = CCLayerColor::create((ccColor4B){0x00, 0x00, 0x00, 0x00}, kCommandButtonWidth, kCommandButtonHeight);
        CCLabelTTF *backTitleLabel = CCLabelTTF::create(MessageBackTitleButtonTitle, DefaultFontName, FontSizeNormal);
        backTitleLabel->setPosition(ccp(kCommandButtonWidth / 2, kCommandButtonHeight / 2));
        backTitleLayer->addChild(backTitleLabel);
        CCMenuItem *backTitleItem = CCMenuItemLabel::create(backTitleLayer,
                                                            GameEngine::sharedEngine(),
                                                            menu_selector(GameEngine::showTitle));

        CCMenu *menu = CCMenu::create(retryItem, backTitleItem, NULL);
        menu->alignItemsHorizontallyWithPadding(kCommandButtonPadding);
        menu->setPosition(ccp(windowSize.width / 2, kCommandAreaMarginBottom + kCommandAreaHeight / 2));
        this->addChild(menu);
    }

    return result;
}
Exemplo n.º 24
0
void GameScene::createGameStateLabels() {
	//背景
	float width = g_visibleSize.width / 1.5;
	float height = 100;

	float x = g_visibleSize.width - width;
	float y = g_visibleSize.height;

	CCDrawNode* node = CCDrawNode::create();
	this->addChild(node);

	ccColor4F color = ccc4f(0, 0, 0, 0.9);
	CCPoint verts[] = { ccp(x, y), ccp(x + width, y),
			ccp(x + width, y - height), ccp(x , y - height) };
	node->drawPolygon(verts, 4, color, 0, color);

	//レベル
	selectedLevel = UserSettings::getSelectedLevel();
	CCString* levelString = CCString::createWithFormat("Level %d",
			selectedLevel + 1);
	CCLabelBMFont* label1 = CCLabelBMFont::create(levelString->getCString(),
			FONT_GREEN);
	label1->setScale(TEXT_SCALE);
	label1->setAnchorPoint(CCPointZero);
	label1->setPosition(g_visibleSize.width * 0.38, g_visibleSize.height - height / 2.15);
	label1->setTag(kTagLevel);
	this->addChild(label1);

	//残りボール数
	CCLabelBMFont* label2 = CCLabelBMFont::create("Balls:", FONT_WHITE);
	label2->setScale(TEXT_SCALE);
	label2->setAnchorPoint(CCPointZero);
	label2->setPosition(label1->getPositionX() * 1.7,
			label1->getPositionY());
	label2->setTag(kTagBallRemainLabel);
	this->addChild(label2);

	//スコア
	CCLabelBMFont* label3 = CCLabelBMFont::create("Score:", FONT_WHITE);
	label3->setScale(TEXT_SCALE);
	label3->setAnchorPoint(CCPointZero);
	label3->setPosition(label1->getPositionX(),
			label2->getPositionY() - label2->getContentSize().height * 0.5);
	label3->setTag(kTagScoreLabel);
	this->addChild(label3);

	//ハイスコア
	CCLabelBMFont* label4 = CCLabelBMFont::create("HighScore:", FONT_WHITE);
	label4->setScale(TEXT_SCALE);
	label4->setAnchorPoint(CCPointZero);
	label4->setPosition(label2->getPositionX(),
			label2->getPositionY() - label2->getContentSize().height * 0.5);
	this->addChild(label4);

	CCString* highScore = CCString::createWithFormat("%d", g_LevelState[1][selectedLevel]);
	CCLabelBMFont* label5 = CCLabelBMFont::create(highScore->getCString(), FONT_ORANGE);
	label5->setScale(TEXT_SCALE);
	label5->setAnchorPoint(CCPointZero);
	label5->setPosition(
			label4->getPositionX() + label4->getContentSize().width * TEXT_SCALE
					+ 10, label4->getPositionY());
	this->addChild(label5);

	showBallRemain();
	showScore();
}
Exemplo n.º 25
0
bool GameWorld::init()
{
	do 
	{
		CC_BREAK_IF(! CCLayer::init());

		CCMenuItemImage *pTransform = CCMenuItemImage::create(
			"6.png",
			"6.png",
			this,
			menu_selector(GameWorld::menuTransformCallback));
		CCMenuItemImage *pLeft = CCMenuItemImage::create(
			"6.png",
			"6.png",
			this,
			menu_selector(GameWorld::menuLeftCallback));
		CCMenuItemImage *pRight = CCMenuItemImage::create(
			"6.png",
			"6.png",
			this,
			menu_selector(GameWorld::menuRightCallback));
		CCMenuItemImage *pDown = CCMenuItemImage::create(
			"6.png",
			"6.png",
			this,
			menu_selector(GameWorld::menuDownCallback));
		CCMenuItemImage *pGameOver = CCMenuItemImage::create(
			"GameOver.jpg",
			"GameOver.jpg",
			this,
			menu_selector(GameWorld::menuGameOver));


		// Place the menu item bottom-right conner.
		CCSize size = CCDirector::sharedDirector()->getWinSize();
		pTransform->setPosition(ccp(size.width - 190, 210));
		pLeft->setPosition(ccp(size.width - 260, 140));
		pRight->setPosition(ccp(size.width - 120, 140));
		pDown->setPosition(ccp(size.width - 190, 70));
		pGameOver->setPosition(ccp(size.width / 2, size.height / 2));
		pGameOver->setScale(5);
		pGameOver->setVisible(false);
		mMenuGameOver = pGameOver;


		// Create a menu with the "close" menu item, it's an auto release object.
		CCMenu* pMenu = CCMenu::create(pTransform, pLeft, pRight, pDown, pGameOver, NULL);
		pMenu->setPosition(CCPointZero);
		CC_BREAK_IF(! pMenu);

		addChild(pMenu, 1);

		CCDrawNode *pDrawNode = CCDrawNode::create();
		addChild(pDrawNode);
		CCPoint points[] = { 
			CCPoint(0,0), 
			CCPoint((CubeManager::MAIN_BOARD_WIDTH)* CubeManager::CUBE_SIZE, 0),
			CCPoint((CubeManager::MAIN_BOARD_WIDTH)* CubeManager::CUBE_SIZE, (CubeManager::MAIN_BOARD_HEIGHT + 1)* CubeManager::CUBE_SIZE),
			CCPoint(0, (CubeManager::MAIN_BOARD_HEIGHT + 1)* CubeManager::CUBE_SIZE)
		};
		pDrawNode->drawPolygon(points, sizeof(points)/sizeof(points[0]), ccc4f(0,0,0.3f,0.5f), 4, ccc4f(0,0,1,1));

		CCLabelTTF* pLabel = CCLabelTTF::create("Score:", "Arial", 56);
		pLabel->setPosition(ccp(size.width - 300, 1100));
		pLabel->setAnchorPoint(ccp(0, 0.5f));
		this->addChild(pLabel);

		pLabel = CCLabelTTF::create("0", "Arial", 56);
		pLabel->setPosition(ccp(size.width - 300, 1000));
		pLabel->setColor(ccc3(255, 192, 0));
		pLabel->setAnchorPoint(ccp(0, 0.5f));
		//pLabel->setHorizontalAlignment(kCCTextAlignmentRight);
		this->addChild(pLabel);
		mLabelScore = pLabel;


		if (!mCubeManager.init(this))
			return false;

		schedule(schedule_selector(GameWorld::stepGo), 0.5f);
		schedule(schedule_selector(GameWorld::checkKeyInput));
		schedule(schedule_selector(GameWorld::onKeyInput), 0.05f);

	} while(0);

	return true;
}
Exemplo n.º 26
0
/*渲染*/
void GameStage::render()
{
	//人物移动和设置手臂和身体的角度
	this->hand->setRotation(this->pukaManCore->roleVo->handRotation);
	this->role->setRotation(this->pukaManCore->roleVo->bodyRotation);
	this->role->setPosition(ccp(this->pukaManCore->roleVo->x, 
								this->pukaManCore->roleVo->y));
	//运动背景移动
	CCDrawNode* drawNode;
	float dis;
	int length = this->drawBgList->count();
	for (int i = 0; i < length; i+=1)
	{
		drawNode = static_cast<CCDrawNode *>(this->drawBgList->objectAtIndex(i));
		if (drawNode->getPositionX() < -drawNode->getContentSize().width)
		{
			//计算移到出边界后的误差,并取绝对值。 重新设置背景的位置并减轻误差。
			dis = (float) abs(drawNode->getPositionX()) - drawNode->getContentSize().width;
			drawNode->setPositionX(drawNode->getContentSize().width - dis);
		}
		drawNode->setPositionX(drawNode->getPositionX() - this->pukaManCore->vx *.5);
	}
	//前景
	length = this->frontBgList->count();
	CCDrawNode* lastDrawNode;
	CCDrawNode* prevDrawNode;
	for (int i = length - 1; i >= 0; i-=1)
	{
		drawNode = static_cast<CCDrawNode *>(this->frontBgList->objectAtIndex(i));
		if (drawNode->getPositionX() <-drawNode->getContentSize().width - this->stageWidth)
		{
			//计算移到出边界后的误差,并取绝对值。 重新设置背景的位置并减轻误差。
			dis = (float) abs(drawNode->getPositionX()) - (drawNode->getContentSize().width + this->stageWidth);
			lastDrawNode = static_cast<CCDrawNode *>(this->frontBgList->objectAtIndex(length - 1));
			drawNode->setPositionX(lastDrawNode->getPositionX() + this->stageWidth - dis);
			this->frontBgList->removeObjectAtIndex(i);
			this->frontBgList->addObject(drawNode);
		}
		
		if(i > 0)
		{
			prevDrawNode = static_cast<CCDrawNode *>(this->frontBgList->objectAtIndex(i - 1));
			drawNode->setPositionX(prevDrawNode->getPositionX() + this->stageWidth);
		}

		float scale = this->pukaManCore->bgWidth / this->stageWidth;
		drawNode->setContentSize(CCSizeMake(this->pukaManCore->bgWidth, 
											drawNode->getContentSize().height));
		drawNode->setScaleX(scale);
		drawNode->setPositionX(drawNode->getPositionX() - this->pukaManCore->vx);
	}
}
Exemplo n.º 27
0
/*创建运动前景*/
CCDrawNode* GameStage::createFrontMotionWall(float x, float y, 
											 float bgWidth, float bgHeight, 
											 int tag)
{
	//前景列表
	CCDrawNode* drawNode = CCDrawNode::create();
	ccColor4F color = ColorUtil::getColor4F(141, 143, 129, 255);
	CCPoint points[] = {CCPoint(x, y), 
						CCPoint(x,  bgHeight + y), 
						CCPoint(x + bgWidth, bgHeight + y), 
						CCPoint(x + bgWidth, y)};
	//顶点列表,顶点数量,颜色
	drawNode->drawPolygon(points, 4, color, 0, ColorUtil::getColor4F(0, 0, 0, 0));

	//前景中段
	float my = y + 97;
	float mHeight = 93;
	color = ColorUtil::getColor4F(103, 107, 82, 255);
	CCPoint points2[] = {CCPoint(x, my), 
						 CCPoint(x,  mHeight + my), 
						 CCPoint(x + bgWidth, mHeight + my), 
						 CCPoint(x + bgWidth, my)};
	drawNode->drawPolygon(points2, 4, color, 0, ColorUtil::getColor4F(0, 0, 0, 0));
	
	mHeight = 3;
	my = my - mHeight;
	color = ColorUtil::getColor4F(86, 90, 67, 255);
	CCPoint points3[] = {CCPoint(x, my), 
						 CCPoint(x,  mHeight + my), 
						 CCPoint(x + bgWidth, mHeight + my), 
						 CCPoint(x + bgWidth, my)};
	drawNode->drawPolygon(points3, 4, color, 0, ColorUtil::getColor4F(0, 0, 0, 0));
	
	mHeight = 2;
	my = my - mHeight;
	color = ColorUtil::getColor4F(100, 103, 82, 255);
	CCPoint points4[] = {CCPoint(x, my), 
						 CCPoint(x,  mHeight + my), 
						 CCPoint(x + bgWidth, mHeight + my), 
						 CCPoint(x + bgWidth, my)};
	drawNode->drawPolygon(points4, 4, color, 0, ColorUtil::getColor4F(0, 0, 0, 0));

	mHeight = 1;
	my = my - mHeight;
	color = ColorUtil::getColor4F(113, 116, 99, 255);
	CCPoint points5[] = {CCPoint(x, my), 
		CCPoint(x,  mHeight + my), 
		CCPoint(x + bgWidth, mHeight + my), 
		CCPoint(x + bgWidth, my)};
	drawNode->drawPolygon(points5, 4, color, 0, ColorUtil::getColor4F(0, 0, 0, 0));
	drawNode->setAnchorPoint(ccp(0, 0));
	drawNode->setContentSize(CCSizeMake(bgWidth, bgHeight));

	//创建阴影 设置注册点在top和center
	CCSprite* shadow = CCSprite::create("shadow.png");
	shadow->setTag(tag);
	shadow->setAnchorPoint(ccp(.5, 1));
	shadow->setPosition(ccp(shadow->getContentSize().width *.5, y));
	drawNode->setTag(tag);
	drawNode->addChild(shadow);
	return drawNode;
}
Exemplo n.º 28
0
bool TipsScene::init()
{
    if ( !CCLayer::init())
    {
        return false;
    }
    
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
	mCallFunc = NULL;
	targetRidus = 100;
	
	//创建一个遮罩层。
	CCLayerColor* pLayer;

	if (isHasTarget && !istouchRemove)
	{
		pLayer=CCLayerColor::create(ccc4(0,0,0,200));

		/*创建剪裁节点*/
		CCClippingNode* pClip = CCClippingNode::create() ;
		pClip->setInverted(true) ;//设置是否反向,将决定画出来的区域是透明的还是黑色的。
		this->addChild(pClip) ;
		/*注意将LayerColor层添加到剪裁节点上*/
		pClip->addChild(pLayer) ;

		//模板
		CCDrawNode* pStencil = CCDrawNode::create() ;
		static ccColor4F red = {1,0,0,1} ;


		float radius = targetRidus/2 ;
		const int nCount = 200 ;
		const float angel = 2.0 * (float)M_PI/nCount ;
		static CCPoint circle[nCount] ;
		for (int i=0; i<nCount; i++) {
			float radian = i*angel ;  //弧度
			circle[i].x = radius * cosf(radian) ;
			circle[i].y = radius * sinf(radian) ;
		}

		pStencil->drawPolygon(circle, nCount, red, 0, red) ;
		pStencil->runAction(CCRepeatForever::create(CCSequence::createWithTwoActions(CCScaleBy::create(0.2f, 0.9f), CCScaleTo::create(0.2f, 1)))) ;

		pStencil->setPosition(targetPoint);
		pClip->setStencil(pStencil) ;  //将这个区域从剪裁节点上面抠出来。Stencil是模板的意思
	}
	else if (shouldPauseGame)
	{
		pLayer=CCLayerColor::create(ccc4(0,0,0,100));
		this->addChild(pLayer) ;
	}
	else
	{
	}

	if (isAutoRemove)
	{
		scheduleOnce(schedule_selector(TipsScene::scheduleResumeGame),2.8);
		scheduleOnce(schedule_selector(TipsScene::scheduleRemove),3.0f);
	}
	
	CCSprite* tipsbg = CCSprite::create("tipbg.png");
	//tipsbg -> setPosition(ccp(375,260));
	tipsbg -> setPosition(ccp(375,260 + 160));
	addChild(tipsbg);

	mTipsWord = CCLabelTTF::create("","Arial",20);
	mTipsWord -> setColor(ccYELLOW);
	//mTipsWord -> setPosition(ccp(400,240));
	mTipsWord -> setPosition(ccp(400,240 + 160));
	addChild(mTipsWord);
	setTouchEnabled(true);

	if (shouldPauseGame)
	{
		BattleManage* pauseLayer = BattleManage::oneself;
		pauseLayer -> pauseSchedulerAndActions();
	}

    return true;
}