Cocos2d 有用的各類方法

從網上收集一些有用的方法,總結一下以便之後複習查找。iphone

內容簡要:spa

一、改變遊戲速度    二、獲取當前屏幕寬高    三、建立一個layer(無貼圖).net

四、在cocos2d中設置橫屏   五、在cocos2d中設置豎屏    六、在cocos2d中設置高清模式 AppDelegate.mcode

七、粒子系統用法   八、進度條   九、設置爲2dblog

十、禁止自動鎖屏
遊戲

原文地址:      http://blog.csdn.net/dingkun520wy/article/details/6999538
ip

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ci

//一、改變遊戲速度
get

[[CCScheduler sharedScheduler] setTimeScale:2.0f];//設置爲正常的2倍it


//二、獲取當前屏幕寬

CGSize size =[[CCDirector sharedDirector]winSize];

 //三、建立一個layer(無貼圖)
CCLayerColor *layer =[CCLayerColor layerWithColor:ccc4(0, 0, 0, 127)];
[self addChild:layer];



//四、在cocos2d中設置橫屏

return ( UIInterfaceOrientationIsLandscape( interfaceOrientation ) );


//五、在cocos2d中設置豎屏

return ( UIInterfaceOrientationIsPortrait( interfaceOrientation ) );



//六、在cocos2d中設置高清模式 AppDelegate.m

[director enableRetinaDisplay:YES] 



//七、粒子系統用法

//添加一個粒子特效
CCParticleSystem *tempSystem = [ARCH_OPTIMAL_PARTICLE_SYSTEM particleWithFile:@"himi.plist"];

//定義位置類型

tempSystem.positionType=kCCPositionTypeRelative;//相對模式

 tempSystem.positionType=kCCPositionTypeFree;//自由模式
tempSystem.position=ccp(100,100);  
[self addChild:tempSystem];



//八、進度條

CCProgressTimer *ct=[CCProgressTimer progressWithFile:@"icon.png"];
ct.position=ccp( size.width /2 , size.height/2); 
[self addChild:ct z:0 tag:90];

ct.percentage = 0; //當前進度
ct.type=kCCProgressTimerTypeHorizontalBarLR;//進度條的顯示樣式


 kCCProgressTimerTypeRadialCCW,         扇形逆時針形式
        kCCProgressTimerTypeRadialCW,          扇形順時針形式
        kCCProgressTimerTypeHorizontalBarLR,   從左往右增張的形式
        kCCProgressTimerTypeHorizontalBarRL,   從右往左增張的形式
        kCCProgressTimerTypeVerticalBarBT,     從下往上增張的形式
        kCCProgressTimerTypeVerticalBarTB,     從上往下增張的形式



//九、設置爲2d

[[CCDirector sharedDirector] setProjection:kCCDirectorProjection2D];



//十、禁止自動鎖屏

 [[UIApplication sharedApplication] setIdleTimerDisabled:YES];

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


iphone有個能判斷硬件朝向的值,當你改變硬件朝向的時候有個標誌位
[[UIDevice currentDevice] orientation];

相關文章
相關標籤/搜索