当前位置: 首页>>代码示例>>C++>>正文


C++ ColorBlock::setPositionY方法代码示例

本文整理汇总了C++中ColorBlock::setPositionY方法的典型用法代码示例。如果您正苦于以下问题:C++ ColorBlock::setPositionY方法的具体用法?C++ ColorBlock::setPositionY怎么用?C++ ColorBlock::setPositionY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ColorBlock的用法示例。


在下文中一共展示了ColorBlock::setPositionY方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CreateBlockCallback

void MainGameScene::CreateBlockCallback(float time)
{
	// create block on a random location
	ColorBlock* newBlock = ColorBlock::create("Assets/block.png");
	// unattached blocks have 50% opacity
	newBlock->setOpacity(127);

	// randomize position
	newBlock->setPositionX(rand() % 800);
	//newBlock->setPositionX(300.0f);
	// Y always in the botton
	newBlock->setPositionY(-80.0f);

	// add as a child to the batch
	blocksBatch->addChild(newBlock);

	newBlock->InitInWorld(box2DWorld);

	// add to local list
	blocksList.push_back(newBlock);

}
开发者ID:digitalhoax,项目名称:fellz,代码行数:22,代码来源:MainGameScene.cpp

示例2: update


//.........这里部分代码省略.........
					CCSequence* warningSequence = CCSequence::create(CCMoveTo::create(4.0f,ccp(400.0f,200.0f)),
						CCCallFuncO::create(this,callfuncO_selector(MainGameScene::DeleteDisctionnectionWarning),discWarning));
					discWarning->runAction(warningSequence);
					discWarning->runAction(CCFadeOut::create(4.0f));//fade
					this->addChild(discWarning,1000);
				}
				// other player just lost
				else if (packet->data[0] == ID_GAME_PLAYER_LOST)
				{
					otherGameOver = true;
				}
				else if (packet->data[0] == ID_GAME_NEW_POINTS)
				{
					// read new points from the other player
					int rs = 0;
					RakNet::BitStream bsIn(packet->data,packet->length,false);
					bsIn.IgnoreBytes(sizeof(RakNet::MessageID));
					bsIn.Read((char*)&rs,sizeof(int));
					pointsManager->SetP2Points(rs);
				}
				else if(packet->data[0] == ID_GAME_INIT_SWAP)
				{
					// other player will swap, prepare
					ChangeScreenSpecial* change = ChangeScreenSpecial::create();
					this->addChild(change,701);
					change->ExecuteActual();
					change->setTag(978);
				}
				else if(packet->data[0] == ID_GAME_SWAP_SCREENS)
				{
					// received information
					std::vector<BlockInformation> received;
					RakNet::BitStream bsIn(packet->data,packet->length,false);
					bsIn.IgnoreBytes(sizeof(RakNet::MessageID));
					// number of blocks within the package
					int size = 0;
					bsIn.Read((char*)&size,sizeof(int));
					BlockInformation* reci = new BlockInformation[size];
					bsIn.Read((char*)reci,sizeof(BlockInformation) * size);
					// put on the received vector
					for (int p = 0; p < size; p++)
					{
						received.push_back(reci[p]);
					}
					delete reci;
					// now change the blocks
					//delete all non-dying blocks
					std::list<ColorBlock*>::iterator it;
					std::vector<ColorBlock*> toDelete;
					for (it = blocksList.begin(); it != blocksList.end(); it++)
					{
						if (!(*it)->GetDying())
						{
							toDelete.push_back(*it);
						}
					}
					//delete them
					for (int c = 0; c < toDelete.size();c++)
					{
						blocksBatch->removeChild(toDelete[c],true);
						blocksList.remove(toDelete[c]);
					}
					//put them back

					for (int c = 0; c < received.size(); c++)
					{
						// create block on a random location
						ColorBlock* newBlock = ColorBlock::create("Assets/block.png");
						// unattached blocks have 50% opacity
						newBlock->setOpacity(127);

						newBlock->setPositionX(received[c].posX);
						newBlock->setPositionY(received[c].posY);

						// add as a child to the batch
						blocksBatch->addChild(newBlock);
						//mainScene->addChild(newBlock);

						newBlock->InitInWorld(box2DWorld);

						if (received[c].color == BLOCK_GREEN)
						{
							newBlock->setColor(ccc3(0,255,0));
						}
						else if (received[c].color == BLOCK_RED)
						{
							newBlock->setColor(ccc3(255,0,0));
						}
						else if (received[c].color == BLOCK_BLUE)
						{
							newBlock->setColor(ccc3(0,0,255));
						}
						// add to local list
						blocksList.push_back(newBlock);
					}
				}
			}
		}
	}
}
开发者ID:digitalhoax,项目名称:fellz,代码行数:101,代码来源:MainGameScene.cpp


注:本文中的ColorBlock::setPositionY方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。