Cocos2D help: How to rotate a sprite continuously and generate child sprites in the rotating sprite

后端 未结 2 2045
伪装坚强ぢ
伪装坚强ぢ 2021-02-10 23:28

I am new to cocos2D can anyone suggest an easy solution to the problem?

I have a windmill with 8 bars on the windmill with each bar separated by 45 degrees, where half o

相关标签:
2条回答
  • 2021-02-11 00:08

    To make a CCSprite to rotate forever you could use something like

    [windmill runAction:[CCRepeatForever actionWithAction:[CCRotateBy actionWithDuration:5.0 angle:360]]];
    

    then add any CCSprite as a child it will rotate too. The position that you assign to a child is based on his parent, take that in account.

    EDIT 1

    Well, if you know the radius of the circle you can make some maths and get the position that you want. But also, if you don't need to calculate the positions, just try & error to get what you want. Try with the windmill without rotation.

    0 讨论(0)
  • 2021-02-11 00:18

    You declare your action, "rot" as an instance of CCRotateBy yet when you allocate it, you begein with [CCRepeatForever[...]]; If you wanted you could do

    CCRotateBy *rot = [CCRotateBy actionWithDuration:5 angle:360];

    [windmill runAction:[CCRepeatForever actionWithAction:rot]];

    0 讨论(0)
提交回复
热议问题