Cocos2d-x 3.2 大富翁游戏项目开发-第二十四部分 彩票开奖(2)
来源:未知 责任编辑:责任编辑 发表时间:2015-09-17 09:43 点击:次
//添加角色图标
void PopupLayer::addPlayersInfo(Size size) { Size winSize = Director::getInstance()->getWinSize(); Size center =(winSize-size)/2; int j=0; for(auto it=players_vector.begin();it!=players_vector.end();it++) { RicherPlayer* player = dynamic_cast(*it); SpriteFrame* spf; int tag = player->getTag(); switch(tag) { case PLAYER_1_TAG: { spf = player->player_spriteFrameCache->getSpriteFrameByName(player1_anim_01.png); break; } case PLAYER_2_TAG: { spf = player->player_spriteFrameCache->getSpriteFrameByName(player2_anim_02.png); break; } } Sprite* playerSprite = Sprite::createWithSpriteFrame(spf); playerSprite->setPosition( center.width+20, (winSize.height/2+50)+j*50); addChild(playerSprite); j++; } }
//添加角色购买的彩票
void PopupLayer::addPlayersLottery() { for(int i=1;i<=30;i++) { if(this->getChildByTag(1000+i) != NULL) { this->removeChildByTag(1000+i); } } Size winSize = Director::getInstance()->getWinSize(); Size size = this->getContentSize(); Size center =(winSize-size)/2; int j=0; for(auto it=players_vector.begin();it!=players_vector.end();it++) { RicherPlayer* player = dynamic_cast(*it); playerLotteryVector.clear(); for(int i=0;i < player->lottery_vector.size();i++) { LabelTTF* labelLotteryNumber = LabelTTF::create(String::createWithFormat(%i,player->lottery_vector.at(i))->getCString(),,15); labelLotteryNumber->setPosition(ccp( center.width+20+(i+1)*20, (winSize.height/2+30)+j*50)); labelLotteryNumber->setColor(Color3B(255,100,100)); labelLotteryNumber->setTag(1000+player->lottery_vector.at(i)); playerLotteryVector.pushBack(labelLotteryNumber); } for(int i=0;i < playerLotteryVector.size();i++) { addChild(playerLotteryVector.at(i)); } j++; } }
//开始摇奖动画
void PopupLayer::runPublishAnmi() { scheduleOnce(schedule_selector( PopupLayer::realRunPublishAnmi),3.0f); }
//开始真正摇奖
void PopupLayer::realRunPublishAnmi(float dt) { lp->runAction(Sequence::create(lp->getNormal_anmi(), CallFunc::create([this]() { int lott = rand()%(30)+1; //四秒后 让开奖画面消失 scheduleOnce(schedule_selector( PopupLayer::dismissFromParent),4.0f); Sprite* ball = Sprite::create(images/orange_ball.png); ball->setPosition(lp->getPosition()-lp->getContentSize()/2 + ccp(0,13)); ball->setAnchorPoint(ccp(0,0)); addChild(ball); LabelTTF* ltf = LabelTTF::create(String::createWithFormat(%02d,lott)->getCString(), , 20); ltf->setPosition(ball->getPosition()+ccp(5,6)); ltf->setAnchorPoint(ccp(0,0)); addChild(ltf); Size winSize = Director::getInstance()->getWinSize(); Size center =(winSize)/2; int j=0; //判断角色是否中奖 for(auto it=players_vector.begin();it!=players_vector.end();it++) { RicherPlayer* player = dynamic_cast
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>