runaction 旋转,使用cocos2d 2.0的iPhone5S上的旋转动画问题

I'm making a CCSprite rotating animation with cocosbuilder2.1, cocos2d 2.0. It works great on iPhone4S(iOS 8.0.2), iPhone5 Simulator, iPad 2 Simulator, iPad Retina Simulator, but has "jittering" problem on iPhone5S(iOS 7.1.1), iPhone5S Simulator, iPad Air Simulator, iPhone 6 Simulator, iPhone 6 Plus Simulator. The build setting is as follows:

In Build Settings under Targets:

Base SDK = Latest iOS (iOS 8.0);

Valid Architectures = arm64 armv7 armv7s

In General under Targets:

Deployment Target = 6.0

At first I thought it's a bug in cocosbuilder, but after testing by manually making a sprite rotating and having the same problem, I feel there's something wrong in cocos2d 2.0's compatibility with iPhone5S.

code:

in the layer of the first scene

-(void)onEnter {

[super onEnter];

...//play music

...//load image resources

CCSprite *testSprite = [CCSprite spriteWithSpriteFrameName:@"testIMG.png"];

testSprite.position = ccp(200,200);

[self addChild:testSprite];

CCRotateBy *rotateAction = [CCRotateBy actionWithDuration:3 angle:360];

[testSprite runAction:rotateAction];

...//other stuff, nothing related with CCBReader or cocosbuilder

}

The "jittering" problem is as if the rotation value of the testSprite has been set to 0 everyFrame ater it's been set to the right value. e.g. It's like it rotates to 1, then back to 0, then to 2, then back to 0, 3, 0, 4, 0 ... etc. And all these happens very quickly, which makes it kind of "blinking". At last the rotation is always reset to 0.

I tried google it, but found nothing related, as if this is a very personal problem. If it's a personal issue, please let me know which direction I should working towards to find where the bug is, thanks!

解决方案

Though still now sure what causes this problem, I solved it by changing the Valid Architectures to armv7. This build settings will not take advantages of new architectures on devices newer than iPhone4S, but at least won't cause the jittering issue.

==============Update=================

I found a warning that's related with this problem. “multiple methods named 'setRotation' ” See related problem: ARC semantic issue "multiple methods named 'setRotation' " while archiving only

Though I've upgraded cocos2d to v2.2 version for my old project (too complex to update to v3), I still got the warning.

Finally I used type casting to solve it as following in CCBAnimationManager.m

@implementation CCBRotateTo

-(void)startWithTarget:(CCNode *)aTarget

{

[super startWithTarget:aTarget];

starAngle_ = [(CCNode *)self.target rotation];

diffAngle_ = dstAngle_ - startAngle_;

}

-(void)update:(ccTime)t

{

[(CCNode *)self.target setRotation: startAngle_ + diffAngle_ * t];

}

With this change, now I can support arm64 too.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值