How can I get screen position of a sprite child?

How can I get screen position of a sprite child?
0.0 0


SpriteA is at (100,100)
SpriteB is child of SpriteA and is at (50,0)

I want to get the position of SpriteB. If I do GetPosition() on it I just get (50,0) as expected but I want to get (150,100) back somehow. The reason I can’t just do the simple math is that SpriteA will scale and rotate which makes the math more complex.

Is there a way to get actual position of SpriteB in the scene?


You can get the real position of SpriteB like this:


Thank you! Did you have a typo? I got the results by doing…




Also, is there a way to do the reverse? For instance, Convert a world coordinate to a coordinate relative to a parent?


It depends what you want.
The reverse way is convertToNodeSpace().


Dear Zhangxm,

can u help me how to change the position of two sprites while drag and drop .

I created two Sprites…like this

CCSprite *splash=CCSprite::create(“Level3.png”);

CCSprite *spla=CCSprite::create("Level4.png");

now i have to swap it…i posted this thing so many portals till now not get any updates at-least you can help me i feel as soon as possible