iphonecocos2d-iphoneccsprite

How to shake CCsprite in cocos2d?


I have a CCSprite in my game, representing an egg. How do I go about shaking it? I tried the following, but without success:

id Runleft = [CCMoveTo actionWithDuration:0.1 position:ccp(244, 156)];
id RunRight = [CCMoveTo actionWithDuration:0.1 position:ccp(236, 156)];
[eggPlay runAction:[CCRepeatForever actionWithAction:[CCSequence actions:Runleft,RunRight,nil]]];

Solution

  • I found a really nice shake for cocos2d-x here. It's a action and can be used with runAction

    http://www.frozax.com/blog/2012/02/how-to-create-shake-action-cocos2d-x-source-code/

    another shake action can be found on the cocos2d forums:

    http://www.cocos2d-iphone.org/forum/topic/20327