Exemplo n.º 1
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.º 2
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.º 3
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.º 4
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;
}