#include "GameBaseScene.h"
int GameBaseScene::tiledColsCount;
int GameBaseScene::tiledRowsCount;
bool** GameBaseScene::canPassGrid;
Vector<RicherPlayer*> GameBaseScene::players_vector;
Vector<Sprite*> GameBaseScene::pathMarkVector;
TMXLayer* GameBaseScene::landLayer;
TMXLayer* GameBaseScene::wayLayer;
TMXTiledMap* GameBaseScene::_map;
int GameBaseScene::blank_land_tiledID;
int GameBaseScene::strength_30_tiledID;
int GameBaseScene::strength_50_tiledID;
int GameBaseScene::strength_80_tiledID;
int GameBaseScene::randomEvent_tiledID;
int GameBaseScene::lottery_tiledID;
int GameBaseScene::stock_tiledID;
int GameBaseScene::player1_building_1_tiledID;
int GameBaseScene::player1_building_2_tiledID;
int GameBaseScene::player1_building_3_tiledID;
int GameBaseScene::player2_building_1_tiledID;
int GameBaseScene::player2_building_2_tiledID;
int GameBaseScene::player2_building_3_tiledID;
Scene* GameBaseScene::createScene()
{
auto scene = Scene::create();
auto layer = GameBaseScene::create();
scene->addChild(layer);
return scene;
}
bool GameBaseScene::init()
{
if ( !Layer::init() )
{
return false;
}
addMap();
initTiledGrid();
setWayPassToGrid();
addRightBanner();
drawTable(2);
addPathMark();
addPlayer();
addGoButton();
registerNotificationObserver();
addDice();
addDigiteRoundSprite();
refreshRoundDisplay();
initLandLayerFromMap();
initPropTiledID();
initPopDialog();
doSomeForParticle();
initRandomAskEvent();
return true;
}
void GameBaseScene::initRandomAskEvent()
{
randomAskEventMap.insert(TAX_REBATES_TAG,__String::create(TAX_REBATES));
randomAskEventMap.insert(PAY_TAXES_TAG,__String::create(PAY_TAXES));
randomAskEventMap.insert(LOSS_STRENGTH_TAG,__String::create(LOSS_STRENGTH));
randomAskEventMap.insert(PHYSICAL_RECOVERY_TAG,__String::create(PHYSICAL_RECOVERY));
randomAskEventMap.insert(INVESTMENT_DIVIDENDS_TAG,__String::create(INVESTMENT_DIVIDENDS));
randomAskEventMap.insert(INVESTMENT_LOSS_TAG,__String::create(INVESTMENT_LOSS));
}
void GameBaseScene::doSomeForParticle()
{
landFadeOut = FadeOut::create(0.1);
landFadeIn = FadeIn::create(0.1);
landFadeOut->retain();
landFadeIn->retain();
scaleby1ForBuyLand = ScaleBy::create(0.1, 1.5);
scaleby2ForBuyLand = ScaleBy::create(0.5, 0.7);
scaleby1ForBuyLand->retain();
scaleby2ForBuyLand->retain();
foot1Sprite = Sprite::create(PLAYER1_1_PARTICLE_PNG);
addChild(foot1Sprite);
foot1Sprite->setAnchorPoint(ccp(0,0));
foot2Sprite = Sprite::create(PLAYER2_1_PARTICLE_PNG);
addChild(foot2Sprite);
foot2Sprite->setAnchorPoint(ccp(0,0));
starFish1Sprite = Sprite::create(PLAYER1_2_PARTICLE_PNG);
addChild(starFish1Sprite);
starFish1Sprite->setAnchorPoint(ccp(0,0));
starFish2Sprite = Sprite::create(PLAYER2_2_PARTICLE_PNG);
addChild(starFish2Sprite);
starFish2Sprite->setAnchorPoint(ccp(0,0));
heart1Sprite = Sprite::create(PLAYER1_3_PARTICLE_PNG);
addChild(heart1Sprite);
heart1Sprite->setAnchorPoint(ccp(0,0));
heart2Sprite = Sprite::create(PLAYER2_3_PARTICLE_PNG);
addChild(heart2Sprite);
heart2Sprite->setAnchorPoint(ccp(0,0));
}
void GameBaseScene::initPopDialog()
{
popDialog = PopupLayer::create(DIALOG_BG);
popDialog->setContentSize(CCSizeMake(Dialog_Size_Width, Dialog_Size_Height));
popDialog->setTitle(DIALOG_TITLE);
popDialog->setContentText("", 20, 60, 250);
popDialog->setCallbackFunc(this, callfuncN_selector(GameBaseScene::buyLandCallback));
popDialog->addButton(BUTTON_BG1, BUTTON_BG3, OK, Btn_OK_TAG);
popDialog->addButton(BUTTON_BG2, BUTTON_BG3, CANCEL, Btn_Cancel_TAG);
this->addChild(popDialog);
popDialog->setVisible(false);
}
void GameBaseScene::initLandLayerFromMap()
{
landLayer = _map->layerNamed("land");
}
void GameBaseScene::addDigiteRoundSprite()
{
gameRoundCount=0;
auto frameCache = SpriteFrameCache::getInstance();
frameCache->addSpriteFramesWithFile("map/digital_round.plist");
digiteRoundVector.pushBack(frameCache->getSpriteFrameByName(DIGITAL_0));
digiteRoundVector.pushBack(frameCache->getSpriteFrameByName(DIGITAL_1));
digiteRoundVector.pushBack(frameCache->getSpriteFrameByName(DIGITAL_2));
digiteRoundVector.pushBack(frameCache->getSpriteFrameByName(DIGITAL_3));
digiteRoundVector.pushBack(frameCache->getSpriteFrameByName(DIGITAL_4));
digiteRoundVector.pushBack(frameCache->getSpriteFrameByName(DIGITAL_5));
digiteRoundVector.pushBack(frameCache->getSpriteFrameByName(DIGITAL_6));
digiteRoundVector.pushBack(frameCache->getSpriteFrameByName(DIGITAL_7));
digiteRoundVector.pushBack(frameCache->getSpriteFrameByName(DIGITAL_8));
digiteRoundVector.pushBack(frameCache->getSpriteFrameByName(DIGITAL_9));
}
void GameBaseScene::refreshRoundDisplay()
{
for(auto it = refreshRoundVector.begin();it != refreshRoundVector.end();it++)
{
((Sprite*) *it)->setVisible(false);
}
refreshRoundVector.clear();
int count = gameRoundCount;
Sprite* st;
if(count ==0 )
{
st = Sprite::createWithSpriteFrame(digiteRoundVector.at(0));
addChild(st);
refreshRoundVector.pushBack(st);
}
while(count!=0)
{
st = Sprite::createWithSpriteFrame(digiteRoundVector.at(count%10));
addChild(st);
refreshRoundVector.pushBack(st);
count = count/10;
}
refreshRoundVector.reverse();
for(int i = 0;i< refreshRoundVector.size();i++)
{
Sprite * sp = refreshRoundVector.at(i);
sp->setPosition(ccp((tableStartPosition_x+50)+(i*25),50));
sp->setVisible(true);
}
}
void GameBaseScene::addPathMark()
{
Sprite* mark1 = Sprite::create(PATH_MARK_1);
Sprite* mark2 = Sprite::create(PATH_MARK_2);
Sprite* mark3 = Sprite::create(PATH_MARK_3);
Sprite* mark4 = Sprite::create(PATH_MARK_4);
Sprite* mark5 = Sprite::create(PATH_MARK_5);
Sprite* mark6 = Sprite::create(PATH_MARK_6);
mark1->setAnchorPoint(ccp(0,0));
mark2->setAnchorPoint(ccp(0,0));
mark3->setAnchorPoint(ccp(0,0));
mark4->setAnchorPoint(ccp(0,0));
mark5->setAnchorPoint(ccp(0,0));
mark6->setAnchorPoint(ccp(0,0));
mark1->setVisible(false);
mark2->setVisible(false);
mark3->setVisible(false);
mark4->setVisible(false);
mark5->setVisible(false);
mark6->setVisible(false);
addChild(mark1);
addChild(mark2);
addChild(mark3);
addChild(mark4);
addChild(mark5);
addChild(mark6);
pathMarkVector.pushBack(mark1);
pathMarkVector.pushBack(mark2);
pathMarkVector.pushBack(mark3);
pathMarkVector.pushBack(mark4);
pathMarkVector.pushBack(mark5);
pathMarkVector.pushBack(mark6);
}
void GameBaseScene::drawPathColor(std::vector<int> rowVector,std::vector<int> colVector)
{
int stepsCount = rowVector.size()-1;
for(int i=1;i<rowVector.size();i++)
{
pathMarkVector.at(i-1)->setPosition(ccp(colVector[i]*32,rowVector[i]*32));
pathMarkVector.at(i-1)->setVisible(true);
}
}
void GameBaseScene::addDice()
{
diceFrameCache= SpriteFrameCache::getInstance();
diceFrameCache->addSpriteFramesWithFile("map/dice.plist","map/dice.png");
Vector<SpriteFrame*> diceVector ;
char name[20];
memset(name, 0, 20);
for (int i=1; i<=6; i++)
{
sprintf(name, "dice_%02d.png",i);
diceVector.pushBack(diceFrameCache->getSpriteFrameByName(name));
}
if(!AnimationCache::getInstance()->getAnimation("dice_animation"))
{
AnimationCache::getInstance()->addAnimation(Animation::createWithSpriteFrames(diceVector,0.1),"dice_animation");
}
dice_animate = Animate::create(AnimationCache::getInstance()->getAnimation("dice_animation"));
dice_animate->retain();
diceSprite =Sprite::createWithSpriteFrame(diceFrameCache->getSpriteFrameByName("dice_01.png"));
diceSprite->setPosition(ccp(tableStartPosition_x+2*tableWidth,tableStartPosition_y-tableHeight*4.5));
addChild(diceSprite);
diceSprite->runAction(RepeatForever::create(dice_animate));
}
voi
没有合适的资源?快使用搜索试试~ 我知道了~
Cocos2d-x 3.2 大富翁游戏项目开发-第十八部分 问号随机事件
共79个文件
png:46个
h:13个
cpp:11个
需积分: 10 50 下载量 165 浏览量
2015-01-08
01:13:31
上传
评论 1
收藏 2.38MB RAR 举报
温馨提示
Cocos2d-x 3.2 大富翁游戏项目开发-第十八部分 问号随机事件
资源推荐
资源详情
资源评论
收起资源包目录
richer0108_第十八部分.rar (79个子文件)
richer0108 第十八部分
Resources
menuLogo.png 135KB
map
sea.png 559KB
player2.png 7KB
mark2.png 5KB
beach_item.png 195KB
player2_anim.plist 8KB
digital_round.png 15KB
go_press.png 11KB
player1_anim.png 44KB
go_normal.png 10KB
dice.png 5KB
stage_background2.png 579KB
sea_item.png 235KB
mark3.png 5KB
right_banner.png 53KB
digital_round.plist 5KB
mark4.png 4KB
moon_item.png 130KB
mark5.png 5KB
mark6.png 5KB
player1_anim.plist 8KB
circle.plist 9KB
circle.png 199KB
player1.png 7KB
mark1.png 4KB
sea.tmx 1KB
dice.plist 3KB
player2_anim.png 40KB
images
circleParticle.png 5KB
stars.png 1KB
foot2.png 4KB
foot1.png 4KB
heart1.png 4KB
showClick.png 5KB
fire.png 722B
fire.plist 3KB
heart2.png 4KB
plane.png 6KB
starfish2.png 4KB
starfish1.png 4KB
showClick.plist 3KB
popuplayer
button_bg1.png 546B
dialog_bg.png 5KB
button_bg2.png 554B
button_bg3.png 543B
press_menu.png 6KB
fonts
Marker Felt.ttf 25KB
mai.png 9KB
normal_menu.9.png 673B
ke.png 9KB
cheng.png 8KB
normal_menu.png 6KB
ji.png 9KB
rainbow.png 37KB
press_menu.9.png 523B
Classes
SplashScene.cpp 3KB
RouteNavigation.h 718B
MenuScene.h 1KB
GameBaseScene.h 4KB
Util.h 2KB
AppDelegate.cpp 1KB
AppDelegate.h 947B
SeaScene.cpp 1KB
MapChooseScene.h 1KB
PopupLayer
PopupLayer.h 1KB
CocosToast.h 389B
CocosToast.cpp 1KB
PopupLayer.cpp 5KB
SplashScene.h 697B
GameBaseScene.cpp 32KB
RicherPlayer.h 2KB
RicherGameController.cpp 10KB
RicherPlayer.cpp 5KB
MenuScene.cpp 7KB
RicherGameController.h 1KB
MapChooseScene.cpp 4KB
RouteNavigation.cpp 4KB
SeaScene.h 361B
ConstUtil.h 4KB
共 79 条
- 1
资源评论
lideguo1979
- 粉丝: 148
- 资源: 77
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功