Identifying sprite associated with a particular body in Box2D

By | April 23, 2011

Hi,

How can you identify the sprite associated with a particular body while using box2D ? Sometimes you may need to identify the sprite associated with the body you are using. For that use the following line of code.

[c]CCSprite *yourSprite= (CCSprite*)yourBody->GetUserData();
[/c]

Now you got the corresponding sprite in your ‘yourSprite’

🙂

One thought on “Identifying sprite associated with a particular body in Box2D

  1. body

    You’ve got great insights about body, keep up the good work!

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *