Tutorial : How to create a shake action in Cocos2d-x (with source code)

Hi,

I posted a small tutorial with source code on how to implement a shake action in cocos2d-x.
Feel free to use the code for your own games.
http://www.frozax.com/blog/2012/02/how-to-create-shake-action-cocos2d-x-source-code/
Hoping some devs will find it useful.

Francois.

2 Likes

hey, nice blog. looking forward to more tutorials :smiley:

Thanks, glad you like it :wink:
I’ll try to write more tutorials, but probably after my game is released, though.

CCActionInterval.h is not recognized in cocos2dx version 2.2.5, what should i Do?

Thanks, but i use cocos2d-x v3 , so there’s no ccTime.

Could you update this code please ?

I have replaced ccTime by float , is this correct ?
there’s two errors :

 CCShake *p_action = new CCShake();  // Allocating an object of abstract class type CCShake

   m_pTarget->setPosition( Point( _initial_x, _initial_y ) );  // use of undeclared identifier 'm_pTarget'

Tanks.

I fixed it :

1- we have to implement two methods :

 virtual CCShake* reverse() const override;
virtual CCShake* clone() const override;

2- change m_pTarget to _target .

Ported this to v3.6