cocos2d iphone - why is userdata set to self? -


in several box2d code samples i've seen line of code:

body->setuserdata(self); 

in search have not found explanation this. main purpose setting userdata self in box2d?

usually assign visual object (ie sprite) userdata object of box2d body contact listeners.

in case of contact callback, receive box2d objects. therefore contact's bodies , body userdata, in order send messages sprite represents body visually.

for example if want run animation on sprite when collides.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -