CCScene场景切换

CCScene场景切换代码:

//触摸事件 - 当手指从屏幕抬起时调用的方法-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];  
} 


设置横竖屏代码

首先找到RootViewController.m 类(此类在1.0版本存在),然后找到宏定义的一段代码,代码如下:
       #elif GAME_AUTOROTATION == kGameAutorotationUIViewController
然后下面能看到cocos2d的默认代码是设置横屏:
return ( UIInterfaceOrientationIsLandscape( interfaceOrientation ) );  


如果想设置竖屏,请更改如下即可:
return (UIInterfaceOrientationIsPortrait(interfaceOrientation));  

你可能感兴趣的:(sc)