Cocos2d 有用的各种方法(转)

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


从网上收集一些有用的方法,总结一下以便以后复习查找。
内容简要:
1、改变游戏速度 2、获取当前屏幕宽高 3、创建一个layer(无贴图)
4、在cocos2d中设置横屏 5、在cocos2d中设置竖屏 6、在cocos2d中设置高清模式 AppDelegate.m
7、粒子系统用法 8、进度条 9、设置为2d
10、禁止自动锁屏
----------------------------------------------------------------------------------------------------------------------------------

//1、改变游戏速度
[[CCScheduler sharedScheduler] setTimeScale:2.0f];//设置为正常的2倍


//2、获取当前屏幕宽高
CGSize size =[[CCDirector sharedDirector]winSize];

//3、创建一个layer(无贴图)
CCLayerColor *layer =[CCLayerColor layerWithColor:ccc4(0, 0, 0, 127)];
[self addChild:layer];

//4、在cocos2d中设置横屏
return ( UIInterfaceOrientationIsLandscape( interfaceOrientation ) );

//5、在cocos2d中设置竖屏
return ( UIInterfaceOrientationIsPortrait( interfaceOrientation ) );

//6、在cocos2d中设置高清模式 AppDelegate.m
[director enableRetinaDisplay:YES]


//7、粒子系统用法
//添加一个粒子特效
CCParticleSystem *tempSystem = [ARCH_OPTIMAL_PARTICLE_SYSTEM particleWithFile:@"himi.plist"];
//定义位置类型
tempSystem.positionType=kCCPositionTypeRelative;//相对模式
tempSystem.positionType=kCCPositionTypeFree;//自由模式
tempSystem.position=ccp(100,100);
[self addChild:tempSystem];

//8、进度条
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, 从上往下增张的形式

//9、设置为2d
[[CCDirector sharedDirector] setProjection:kCCDirectorProjection2D];

//10、禁止自动锁屏
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
-----------------------------------------------------------------------------------------------------------------------------------------------------------------

iphone有个能判断硬件朝向的值,当你改变硬件朝向的时候有个标志位
[[UIDevice currentDevice] orientation];
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值