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];

相关文章
相关标签/搜索