开发者

How to switch sprite animation with cocos2d?

I have two animations 开发者_如何学JAVAof a goalkeeper with two different states (with ball and without ball). After keeper jumps I want to switch to a different action but I want to stay at the same frame index.

I mean if goalkeeper collides with the ball in the frame 19, the second action should start at frame 19 too.


I'm still not quite sure if I completely understand what your trying to do but I can help you with that action. If you want to run a check every frame you should do somethng like this

At the end of your scenes init method add:

` [self schedule: @selector(tick:) interval: 0.3f];

-(void)tick:(ccTime) dt { if(CGRectIntersectsRect(goalKeeper.textureRect, ball.textureRect) { [goalKeeper stopAction: myAction]; //where myAction is previously defined } //now you can start the new action because you're using a timer, it'll be the same frame

That should do it. I hope that helps, if I still didn't quite answer your question feel free to clarify what in more vivid what exactly you're going for. `

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜