About sprite take with physics body, sprite postion change...why?

helloy guys:)
when i create a sprite or node, take with physics body, when set the sprite position is vec2(200,200), when run the demo, the sprite position is not right. anybody know why? thanks.

well if you are in box2d world , box2d its in meters so you have to do always
you need some kind of conversion between pixels and meters
define PIXEL_TO_METER_RATIO_DEFAULT 32.0f

here is good tutorial in cocos2d objC version that can be easily read in c++
look for PTM_RATIO string in the tutorial ( its the unit conversion 32.0f) .
http://www.raywenderlich.com/28602/intro-to-box2d-with-cocos2d-2-x-tutorial-bouncing-balls

hi @rickystone

what i guessed from your query that, you are adding a physics body to the sprite later on, and that changes the position of the sprite right… ??

If I guessed correctly, here’s my next question -
what is the anchor point of your sprite ?
because when you add a physics body to a sprite, it’s anchor point changes to (0.5, 0.5)
So, if you are using different anchor points, that will change after you add physics body.

If I am wrong, please explain the situation in a little bit detail, I would love to help.

Happy Coding :smile: