cocos2d-x中的场景管理

在SceneManager中申明一个静态方法

 

void SceneManager::runThisScene(CCLayer* layer,float time)
{   
	CCSize size = CCDirector::sharedDirector()->getWinSize();
	CCDirector* director = CCDirector::sharedDirector();
	CCScene* scene = CCScene::node();
	layer->setScale(((float)size.height/768.0f));
	scene->addChild(layer);
	layer->release();
	if(director->getRunningScene())
	{
		
		CCScene* scene2 = CCTransitionFade::transitionWithDuration(time, scene);
		director->replaceScene(scene2);
		scene2=NULL;
	}
	else
	{
		director->runWithScene(scene);
		scene->cleanup();
	}
}

 

切换场景

 

在SceneManager中定义静态函数

 

void SceneManager::callGardenBegin()
{
	CCLayer * gardenGame=new GardenBegin();

	runThisScene(gardenGame,1);
	gardenGame=NULL;
}

 

场景中动画切换,将scene传进来,返回一个新的Scene

CCScene* scene2 = CCTransitionFade::transitionWithDuration(time, scene);

 

CCTransitionJumpZoom::transitionWithDuration(t, s);//跳跃式,本场景先会缩小,然后跳跃进来

CCTransitionFade::transitionWithDuration(t, s);//淡出淡入,原场景淡出,新场景淡入

CCTransitionFade::transitionWithDuration(t, s, ccWHITE);//如果上一个的函数,带3个参数,则第三个参数就是淡出淡入的颜色

CCTransitionFlipX::transitionWithDuration(t, s, kOrientationLeftOver);//x轴左翻

CCTransitionFlipX::transitionWithDuration(t, s, kOrientationRightOver);//x轴右翻

CCTransitionFlipY::transitionWithDuration(t, s, kOrientationUpOver);//y轴上翻

CCTransitionFlipY::transitionWithDuration(t, s, kOrientationDownOver);//y轴下翻

CCTransitionFlipAngular::transitionWithDuration(t, s, kOrientationLeftOver);//有角度转的左翻

CCTransitionFlipAngular::transitionWithDuration(t, s, kOrientationRightOver);//有角度转的右翻

CCTransitionZoomFlipX::transitionWithDuration(t, s, kOrientationLeftOver);//带缩放效果x轴左翻

CCTransitionZoomFlipX::transitionWithDuration(t, s, kOrientationRightOver);//带缩放效果x轴右翻

CCTransitionZoomFlipY::transitionWithDuration(t, s, kOrientationUpOver);//带缩放效果y轴上翻

CCTransitionZoomFlipY::transitionWithDuration(t, s, kOrientationDownOver);//带缩放效果y轴下翻 

CCTransitionZoomFlipAngular::transitionWithDuration(t, s, kOrientationLeftOver);//带缩放效果/有角度转的左翻

CCTransitionZoomFlipAngular::transitionWithDuration(t, s, kOrientationRightOver);//带缩放效果有角度转的右翻

CCTransitionShrinkGrow::transitionWithDuration(t, s);//交错换

CCTransitionRotoZoom::transitionWithDuration(t, s);//转角换

CCTransitionMoveInL::transitionWithDuration(t, s);//新场景从左移入覆盖

CCTransitionMoveInR::transitionWithDuration(t, s);//新场景从右移入覆盖

CCTransitionMoveInT::transitionWithDuration(t, s);//新场景从上移入覆盖

CCTransitionMoveInB::transitionWithDuration(t, s);//新场景从下移入覆盖

CCTransitionSlideInL::transitionWithDuration(t, s);//场景从左移入推出原场景

CCTransitionSlideInR::transitionWithDuration(t, s);//场景从右移入推出原场景

CCTransitionSlideInT::transitionWithDuration(t, s);//场景从上移入推出原场景

CCTransitionSlideInB::transitionWithDuration(t, s);//场景从下移入推出原场景

以下两个需要先设置摄像机,使用CCDirector::sharedDirector()->setDepthTest(true);

CCTransitionPageTurn::transitionWithDuration(t, s, false);//翻页,前翻

CCTransitionPageTurn::transitionWithDuration(t, s, true);//翻页,后翻

CCTransitionFadeTR::transitionWithDuration(t, s);//向右上波浪

CCTransitionFadeBL::transitionWithDuration(t, s);//向左下波浪

CCTransitionFadeUp::transitionWithDuration(t, s);//向上百叶窗

CCTransitionFadeDown::transitionWithDuration(t, s);//向下百叶窗

CCTransitionTurnOffTiles::transitionWithDuration(t, s);//随机小方块

CCTransitionSplitRows::transitionWithDuration(t, s);//按行切

CCTransitionSplitCols::transitionWithDuration(t, s);//按列切

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值