Bounce after a hit

Bounce after a hit
0.0 0


Let’s say there are two sprites: A and B. A is moving. When A hits B, the sprite B should “bounce” and start moving. I know how to implement such behavior “manually” without cocos2d physical engine. But probably with the physical engine it will be easier, right? What engine API should I look at?


I think you can try integrated physics module which only exists in v3.0. If you use v2.x, you should use Box2D or chipmunk by your self.


What API of the integrated physics module should I look at? Do you have an example?


Hi, You may have a look at the PhysicsSprite class to start.

Cocos2d-x provides also quite a lot of examples. Please have a look at samples/Cpp/TestCpp/Classes/PhysicsTest from your cocos2dx distribution (box2d and chipmuck examples are also available).

If you have any questions don’t hesitate. :wink: