addComponent vs. setPhysicsBody methods to add a physics body to a sprite/node

I’ve noticed in the TestCPP sample code for Physics using the sprite->addComponent(myPhysBody) method, while in the past it used to be sprite->setPhyscisBody(myPhysBody);I looked online and in this forum for explainations which is the correct way to add physics body to a node and how to do collision detection but have not found much.

I’ve ran into some issue where my app compiles and runs with no issues on WIN32 and iOS simulator, but crashes when launched on Android device. I’ve narrowed it down to a sprite that has multiple shapes on a physics body that is causing the app to crash so would appreciate if someone can help or guide me. I created my physics shapes using PhysicsEditor, but trying now create the same physics object manually in code to triage the issue.

If you are < v3.9 use setPhysicsBody(). If you are >= 3.9 use addComponent()

http://cocos2d-x.org/docs/programmers-guide/11/index.html

I’m a bit confused with your reply. The link you provided to the Cocos documentation uses addComponent() method, while in your comments you are saying use setPhysicsBody()

Can you please clarify?

typo. fixed. I apologize.