how can I use animation in cocos2d?

后端 未结 4 575
广开言路
广开言路 2020-12-02 12:41

I am trying to develop a Roulette game for iPhone. How can I animation (spin) the Roulette board?

4条回答
  •  误落风尘
    2020-12-02 13:18

    It's quite simple in Cocos2D:

    [sprite runAction:[RotateBy actionWithDuration:dur angle:360]];
    

    to make one turn or

    id action = [RepeatForever actionWithAction: [RotateBy actionWithDuration:dur angle:360]];
    [sprite runAction:action];
    

    and

    [sprite stopAction:action];
    

    if you need to rotate continuously.

    Don't forget to make sure that sprite transformAnchor is set to center of the image. And I guess next question should arise - how to make it stop smoothly ;)

    More on actions: http://lethain.com/entry/2008/oct/03/notes-on-cocos2d-iphone-development (it's for older version, so it uses deprecated 'do' instead of 'runAction')

提交回复
热议问题