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
	
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
用户名: 验证码:点击我更换图片
最新评论 更多>>

推荐热点

  • cocos2d-x学习笔记(19)--label 、label atlas
  • cocos2d-x学习笔记(23)--地图的使用3--CCTMXLayer
  • Cocos2d-x 2.0 之 Actions “三板斧” 之一
  • Cocos2d-x学习(一):HelloWorld
  • cocos2d-x学习笔记(18)--游戏打包(windows平台)
  • cocos2d 设置屏幕默认方向
  • cocos2d-x学习笔记(16)--spritesheet(精灵表单)
  • cocos2d-x学习笔记(15)--地图的使用(TMX)
  • cocos2dx在xcode下开发,编译到android上(2)
网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
Copyright © 2008-2015 计算机技术学习交流网. 版权所有

豫ICP备11007008号-1