本文整理汇总了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);
}
示例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);
}
}
}
}
}
}