CCScene 对于使用cocos2d的童鞋肯定很熟悉,那么在使用 [[
CCDirector
sharedDirector]
replaceScene:<#(CCScene *)scene#>]; 对scene进行场景(CCLayout)进行切换时,cocos2d提供了一些特效进行过渡,那么今天仔细翻开cocos2d源码,将所有的动画效果都测试了一遍,大概整理如下,提供大家查阅和使用吧;
下面我来给大家介绍如何在cocos2d 1.0版本中设置竖屏显示,因为默认是横屏;
因为我使用的是最新的cocos2d的1.0版本,所以一些函数方法跟之前不一样了,所以不要感到奇怪;
由于代码都有备注,所以就直接上代码了,就不详细单独解释了;关于注释的都是我的直观体验,推荐大家放到自己项目中,自己都看看每个的效果,这样记忆深刻;
- //触摸事件 - 当手指从屏幕抬起时调用的方法-Himi
- -(void) ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
- {
- CCScene* scenec = [OtherLayout scene];
- //部落格------
- //CCTransitionTurnOffTiles *transitionScene = [CCTransitionTurnOffTiles transitionWithDuration:3 scene:scenec];
- //近远-远近-----
- //CCTransitionShrinkGrow *transitionScene = [CCTransitionShrinkGrow transitionWithDuration:3 scene:scenec];
- //另一个layout左侧进入(视觉感觉是屏幕右移)
- //CCTransitionSlideInL *transitionScene = [CCTransitionSlideInL transitionWithDuration:3 scene:scenec];
- //另一个layout右侧进入(视觉感觉是屏幕左移)
- //CCTransitionSlideInR *transitionScene = [CCTransitionSlideInR transitionWithDuration:3 scene:scenec];
- //另一个layout上侧进入(视觉感觉是屏幕下移)
- //CCTransitionSlideInT *transitionScene = [CCTransitionSlideInT transitionWithDuration:3 scene:scenec];
- //另一个layout下侧进入(视觉感觉是屏幕上移)
- //CCTransitionSlideInB *transitionScene = [CCTransitionSlideInB transitionWithDuration:3 scene:scenec];
- //当前屏幕被分为3列,两则下移,中间上移
- //CCTransitionSplitCols *transitionScene = [CCTransitionSplitCols transitionWithDuration:3 scene:scenec];
- //当前屏幕被分为3列,两则左移,中间右移
- //CCTransitionSplitRows *transitionScene = [CCTransitionSplitRows transitionWithDuration:3 scene:scenec];
- //扇形转换-----
- //CCTransitionRadialCW *transitionScene = [CCTransitionRadialCW transitionWithDuration:3 scene:scenec];
- //平面旋转-----
- //CCTransitionRotoZoom *transitionScene = [CCTransitionRotoZoom transitionWithDuration:3 scene:scenec];
- //近-远-跳动------
- //CCTransitionJumpZoom *transitionScene = [CCTransitionJumpZoom transitionWithDuration:3 scene:scenec];
- //立体反转(X轴)--(还有种从近到远,从远到近的感觉)--------
- //CCTransitionZoomFlipX *transitionScene = [CCTransitionZoomFlipX transitionWithDuration:3 scene:scenec];
- //立体反转(Y轴)-(还有种从近到远,从远到近的感觉)-------
- //CCTransitionZoomFlipY *transitionScene = [CCTransitionZoomFlipY transitionWithDuration:3 scene:scenec];
- //立体反转(X,Y轴)---(还有种从近到远,从远到近的感觉)-----
- //CCTransitionZoomFlipAngular *transitionScene = [CCTransitionZoomFlipAngular transitionWithDuration:3 scene:scenec];
- //另外一个layout左侧进入覆盖当前layout
- //CCTransitionMoveInL *transitionScene = [CCTransitionMoveInL transitionWithDuration:3 scene:scenec];
- //另外一个layout右侧进入覆盖当前layout
- //CCTransitionMoveInR *transitionScene = [CCTransitionMoveInR transitionWithDuration:3 scene:scenec];
- //另外一个layout上侧进入覆盖当前layout
- //CCTransitionMoveInT *transitionScene = [CCTransitionMoveInT transitionWithDuration:3 scene:scenec];
- //另外一个layout下侧进入覆盖当前layout
- //CCTransitionMoveInB *transitionScene = [CCTransitionMoveInB transitionWithDuration:3 scene:scenec];
- //立体反转(X轴)--2D平面反转,没有远近感
- //CCTransitionFlipX *transitionScene = [CCTransitionFlipX transitionWithDuration:3 scene:scenec];
- //立体反转(Y轴)--2D平面反转,没有远近感
- //CCTransitionFlipY *transitionScene = [CCTransitionFlipY transitionWithDuration:3 scene:scenec];
- //立体反转(X,Y轴)--2D平面反转,没有远近感
- //CCTransitionFlipAngular *transitionScene = [CCTransitionFlipAngular transitionWithDuration:3 scene:scenec];
- //实体-透明-实体(默认无颜色,可以附带颜色)
- //CCTransitionFade* transitionScene = [CCTransitionFade transitionWithDuration:3 scene:scenec withColor:ccWHITE];
- //另外一个直接渐变覆盖当前layout
- //CCTransitionCrossFade *transitionScene = [CCTransitionCrossFade transitionWithDuration:3 scene:scenec];
- //移动(方格状)部落格,从左下往右上
- //CCTransitionFadeTR *transitionScene = [CCTransitionFadeTR transitionWithDuration:3 scene:scenec];
- //移动(方格状)部落格,从右上往左下
- CCTransitionFadeBL *transitionScene = [CCTransitionFadeBL transitionWithDuration:3 scene:scenec];
- //移动(长矩形,宽度是屏幕宽)部落格,从下往上
- //CCTransitionFadeUp *transitionScene = [CCTransitionFadeUp transitionWithDuration:3 scene:scenec];
- //移动(长矩形,宽度是屏幕宽)部落格,从上往下
- //CCTransitionFadeDown *transitionScene = [CCTransitionFadeDown transitionWithDuration:3 scene:scenec];
- [[CCDirector sharedDirector] replaceScene: transitionScene];
- }
下面我来给大家介绍如何在cocos2d 1.0版本中设置竖屏显示,因为默认是横屏;
首先找到RootViewController.m 类(此类在1.0版本存在),然后找到宏定义的一段代码,代码如下:
#elif GAME_AUTOROTATION == kGameAutorotationUIViewController
然后下面能看到cocos2d的默认代码是设置横屏:
- return ( UIInterfaceOrientationIsLandscape( interfaceOrientation ) );
如果想设置竖屏,请更改如下即可:
- return (UIInterfaceOrientationIsPortrait(interfaceOrientation));