iphone 游戏开发备忘

1. iphone/ipad 禁止系统自动休眠
//禁止自动休眠可以通过这一句话搞定:
[UIApplication sharedApplication].idleTimerDisabled=YES;

//当然一定要慎用,记着退出程序时把自动休眠功能开启
UIApplication sharedApplication].idleTimerDisabled=NO;

2. 精灵碰撞检测
CGRect projectileRect = CGRectMake(projectile.position.x ,    projectile.position.y ,   projectile.contentSize.width  ,    projectile.contentSize.height );

CGRect targetRect = CGRectMake(target.position.x ,    target.position.y ,  target.contentSize.width,    target.contentSize.height);
            
if (CGRectIntersectsRect(projectileRect, targetRect)) {
         // 碰撞了.            
} 
                      

第一个代表rect是a物体在屏幕上占的空间.第二个rect是b物体占的空间.两个空间相交则表示碰撞了.
现在 正在做的游戏中用到了.

3. 编译无法上真机
错误提示
Couldn't register XXX(授权文件名称) with the bootstrap server. Error: unknown error code.
This generally means that another instance of this process was already running or is hung in the debugger.

[解决办法]
重启iphone

[导致问题的原因]
错误的插拔数据线,在debug联机状态,没有停止debug而直接拔掉数据线.


4. cocos2d 动画

http://www.cnblogs.com/ylucy/archive/2010/12/04/1896562.html


5. 心脏缚动动画
lbl_taskwin.anchorPoint = ccp( 0.5, 0.5 ); //center the pivot
    id a1 = [CCScaleTo actionWithDuration:1 scaleX:1.2 scaleY:1.2];
    id a2 = [CCScaleTo actionWithDuration:1 scaleX:1 scaleY:1];
    id action = [CCRepeatForever actionWithAction: [CCSequence actions:a1, a2, nil]];
    [lbl_taskwin runAction:action];

6. 布料背景:
[UIColor scrollViewTexturedBackgroundColor];

7. IOS5 UISegmentedControl变更

你可能感兴趣的:(iPhone)