欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

cocos2d 场景切换和弹出场景、收回场景

程序员文章站 2022-03-16 09:56:02
...

 

场景弹出收回很简单

 

用以下代码在任意一个地方显示“设置场景”: [[CCDirector sharedDirector] pushScene:[Settings scene]];

如果你身处“设置场景”,但又想关闭“设置场景”时,你可以调用popScene。 这样你会回到之前还保留在内存里的场景:
[[CCDirector sharedDirector] popScene]; 

 

CCScene* sence = [Setting scene];

//单纯的场景切换就是这样。

 

[[CCDirectorsharedDirector] replaceScene:sence];

 

如果要加效果的话,就用下面的代码替换上面这一行。

 

/*场景切换效果*/

//淡入淡出

//CCTransitionCrossFade* transition = [CCTransitionCrossFade transitionWithDuration:3 scene:sence];

//CCTransitionFade* transition = [CCTransitionFade transitionWithDuration:3 scene:sence];

//CCTransitionFadeDown* transition = [CCTransitionFadeDown transitionWithDuration:3 scene:sence];

//CCTransitionFadeTR* transition = [CCTransitionFadeTR transitionWithDuration:3 scene:sence];

//CCTransitionFadeBL* transition = [CCTransitionFadeBL transitionWithDuration:3 scene:sence];

//CCTransitionFadeUp* transition = [CCTransitionFadeUp transitionWithDuration:3 scene:sence];

 

//翻转效果

//CCTransitionFlipAngular* transition = [CCTransitionFlipAngular transitionWithDuration:3 scene:sence];

//CCTransitionFlipX* transition = [CCTransitionFlipX transitionWithDuration:3 scene:sence];

//CCTransitionFlipY* transition = [CCTransitionFlipY transitionWithDuration:3 scene:sence];

 

//弹跳

//CCTransitionJumpZoom* transition = [CCTransitionJumpZoom transitionWithDuration:3 scene:sence];

 

//切入

//CCTransitionMoveInB* transition = [CCTransitionMoveInB transitionWithDuration:3 scene:sence];

//CCTransitionMoveInL* transition = [CCTransitionMoveInL transitionWithDuration:3 scene:sence];

//CCTransitionMoveInR* transition = [CCTransitionMoveInR transitionWithDuration:3 scene:sence];

//CCTransitionMoveInT* transition = [CCTransitionMoveInT transitionWithDuration:3 scene:sence];

 

//翻页效果

//CCTransitionPageTurn* transition = [CCTransitionPageTurn transitionWithDuration:3 scene:sence];

 

//扇面展开收起

//CCTransitionRadialCCW* transition = [CCTransitionRadialCCW transitionWithDuration:3 scene:sence];

//CCTransitionRadialCW* transition = [CCTransitionRadialCW transitionWithDuration:3 scene:sence];

 

//旋转

//CCTransitionRotoZoom* transition = [CCTransitionRotoZoom transitionWithDuration:3 scene:sence];

 

//推远拉近

//CCTransitionShrinkGrow* transition = [CCTransitionShrinkGrow transitionWithDuration:3 scene:sence];

 

//滑动

//CCTransitionSlideInB* transition = [CCTransitionSlideInB transitionWithDuration:3 scene:sence];

//CCTransitionSlideInL* transition = [CCTransitionSlideInL transitionWithDuration:3 scene:sence];

//CCTransitionSlideInR* transition = [CCTransitionSlideInR transitionWithDuration:3 scene:sence];

//CCTransitionSlideInT* transition = [CCTransitionSlideInT transitionWithDuration:3 scene:sence];

 

//条状

//CCTransitionSplitCols* transition = [CCTransitionSplitCols transitionWithDuration:3 scene:sence];

//CCTransitionSplitRows* transition = [CCTransitionSplitRows transitionWithDuration:3 scene:sence];

 

//扣块

 

CCTransitionTurnOffTiles* transition = [CCTransitionTurnOffTilestransitionWithDuration:3scene:sence];

 

 

[[CCDirectorsharedDirector] replaceScene:transition];

 

每个效果都试了,可能你想用更炫的,那就要自己想办法了。

 

另看到有人整理了好多的字体,留下以后参考吧。之前做的很多和设计的不一样。

http://www.himigame.com/iphone-cocos2d/444.html

相关标签: 场景切换