Cocos2d-x 3.2 大富翁游戏项目开发-第二十四部分 彩票开奖
来源:未知 责任编辑:责任编辑 发表时间:2015-09-17 09:43 点击:次
每隔N个回合,彩票开奖一次,每期开奖奖金固定5万,暂不累积。摇奖效果一般,以后考虑用物理引擎实现
2、创建开奖画面的对话框。
3、在PopupLayer.h中添加开奖对话框枚举LOTTERY_PUBLISH
1、定义彩票开奖类
bool LotteryPublish::init() { addItemSpriteFrameCache(); SpriteFrame* spf; spf = itemSpriteFrameCache->getSpriteFrameByName(publish_ly01.png); Sprite::initWithSpriteFrame(spf); setItemAnimate(); return true; } void LotteryPublish::addItemSpriteFrameCache() { itemSpriteFrameCache = SpriteFrameCache::getInstance(); itemSpriteFrameCache->addSpriteFramesWithFile(images/publish_ly.plist,images/publish_ly.png); memset(name, 0, 20); for (int i=1; i<=21; i++) { sprintf(name, publish_ly%02d.png,i); item_anim_vector.pushBack(itemSpriteFrameCache->getSpriteFrameByName(name)); } } //开奖动画 void LotteryPublish::setItemAnimate() { if(!AnimationCache::getInstance()->getAnimation(publish_ly_animation)) { AnimationCache::getInstance()->addAnimation(Animation::createWithSpriteFrames(item_anim_vector,0.1f),publish_ly_animation); } normal_anmi = Animate::create(AnimationCache::getInstance()->getAnimation(publish_ly_animation)); normal_anmi->retain(); }
2、创建开奖画面的对话框。
void GameBaseScene::initPopPublishLottery() { popDialogLottery = PopupLayer::create(DIALOG_BG); popDialogLottery->setContentSize(CCSizeMake(Dialog_Size_Width, Dialog_Size_Height+180)); popDialogLottery->setTitle(LanguageString::getInstance()->getLanguageString(PUBLISH_LOTTERY)->getCString()); popDialogLottery->setContentText(, 20, 60, 250); popDialogLottery->setPopType(LOTTERY_PUBLISH);//开奖类型的对话框 popDialogLottery->setPlayerVector(players_vector);//传入角色容器,开奖画面会根据这个显示角色购买的彩票号码 popDialogLottery->setTag(100); this->addChild(popDialogLottery); popDialogLottery->setVisible(false); } 在显示Go按钮之前,根据回合数显示开奖界面 void GameBaseScene::receivedNotificationOMsg(Object* data) { ............. case MSG_GO_SHOW_TAG: { //便于测试,每一回合结束都显示开奖画面 if(gameRoundCount !=0 && gameRoundCount%1 == 0) { //前面角色买地等,会播放动画,所以这里延迟一下,显示开奖画面 scheduleOnce(schedule_selector( GameBaseScene::popPublishLottery),2.0f); }else { showGoButton(); } break; } ............ } //把开奖画面显示出来,并播放摇奖动画 void GameBaseScene::popPublishLottery(float dt) { popDialogLottery->setVisible(true); //开奖画面中添加角色购买的彩票号码 popDialogLottery->addPlayersLottery(); //播放摇奖动画 popDialogLottery->runPublishAnmi(); }
3、在PopupLayer.h中添加开奖对话框枚举LOTTERY_PUBLISH
enum POP_TYPE { NORMAL, LOTTERY, LOTTERY_PUBLISH, STOCK, }; //当对话框进入后调用setPublishLotteryContext,在对话框中添加开奖画面 void PopupLayer::onEnter() { ...... case LOTTERY_PUBLISH: { setPublishLotteryContext(contentSize); break; } ..... } //在对话框中添加开奖画面 void PopupLayer::setPublishLotteryContext(Size size) { Size winSize = Director::getInstance()->getWinSize(); lp = LotteryPublish::create(); addChild(lp); lp->setPosition((winSize)/2); addPlayersInfo(size); }
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>