本文整理汇总了C++中GameScene::initTurn方法的典型用法代码示例。如果您正苦于以下问题:C++ GameScene::initTurn方法的具体用法?C++ GameScene::initTurn怎么用?C++ GameScene::initTurn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameScene
的用法示例。
在下文中一共展示了GameScene::initTurn方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GameLogic
GameScene::GameScene(SceneRunner* const sceneRunner, std::shared_ptr<GameDb> gameDb, bool winOn4, bool reuseLost)
:Scene(sceneRunner){
//initialize variables
::gameDb = gameDb;
::winOn4 = winOn4;
for(int i=0; i<uncollectedCardsNum; i++)
uncolldectedCards[i] = nullptr;
gameLogic = std::shared_ptr<GameLogic>(new GameLogic(gameDb.get(), winOn4, reuseLost));
playerNum = gameLogic->getPlayers().size();
//attach event handllers
gameLogic->drawCardHook = [=](Card card){ this->drawCard(card); };
gameLogic->collectCardHook = [=](std::vector<Player> oldStates, Card card){ this->collectCard(oldStates, card); };
gameLogic->lostHook = [=](){ this->cardsLost(); };
gameLogic->nextTurnHook = [=](){
GameScene* DIS = this;
this->add(new Timer([=]{ DIS->initTurn(); }, nextTurnDelay));
};
gameLogic->gameEndHook = [=](){
GameScene* DIS = this;
this->add(new Timer([=]{ DIS->gameEnd(); }, nextTurnDelay));
};
//add background
SpriteObject* background = new SpriteObject(Vec2(0, 0), Vec2(800, 650), "./assets/background.png", Vec2(0, 0), Vec2(800, 600));
this->add( new Animator<double>(background->tileIndex.x, 1e10, 1e10/50) );
this->add(background);
//construct game board
gameBoardPanel = new Panel(Vec2(30, 205), Vec2(800, 270), Color(0, 0, 0, 0), 0, Color(0, 0, 0, 0));
//add game board(background)
SpriteObject* gameBoard = new SpriteObject(Vec2(-30, -35), Vec2(800, 270), "./assets/gamescene/board.png");
gameBoardPanel->add(gameBoard);
//add flip and collect buttons
flipMoreButton = new Button(Vec2(0, 40), Vec2(100, 30), "More", Color(1,1,0,1), Color(0.5,0.5,0.6,1));
collectCardsButton = new Button(Vec2(0, 110), Vec2(100, 30), "Collect", Color(1,1,0,1), Color(0.5,0.5,0.6,1));
flipMoreButton->action = [=](){ gameLogic->drawCard(); };
collectCardsButton->action = [=](){ gameLogic->collectCards(); };
gameBoardPanel->add(flipMoreButton);
gameBoardPanel->add(collectCardsButton);
//add card deck
cardDeckSprite = new SpriteObject(Vec2(gameBoardPanel->size.x-220, 22), Vec2(100, 150), "./assets/gamescene/cards.png", Vec2(0, 0), Vec2(100, 150));
gameBoardPanel->add(cardDeckSprite);
cardDeckNumText = new Text(cardDeckSprite->pos+cardDeckSprite->size*0.5-Vec2(50/2, 30/2), Vec2(50, 30), "", 20, Color(1, 1, 1, 1), Text::CENTER);
this->updateDeckCardsNum();
gameBoardPanel->add(cardDeckNumText);
this->add(gameBoardPanel);
for(int i=0; i<playerNum; i++){
sp[i].statusPlate = new Panel(platePos[i], Vec2(800, 270), Color(0, 0, 0, 0), 0, Color(0, 0, 0, 0));
sp[i].statusPlateBackground
= new SpriteObject(Vec2(0, 0), Vec2(735, 90), "./assets/gamescene/statusPlate.png");
sp[i].statusPlate->add(sp[i].statusPlateBackground);
Text* playerName = new Text(Vec2(10, 0), Vec2(0, 0), gameDb->getUserName(i), 20);
sp[i].statusPlate->add(playerName);
this->add(sp[i].statusPlate);
}
stopBgm();
initTurn();
}