Monday, 15 June 2015

actionscript 3 - [AS3][Nape Physics] How to access associated object of a Nape body in a InteractionListener? -



actionscript 3 - [AS3][Nape Physics] How to access associated object of a Nape body in a InteractionListener? -

i need help physics engine nape in as3. have class rectangles (nape bodies) fellow member variables. have interactionlistener reacts when these rectangles interacts circles (also nape bodies) in scene. however, need access class instance rectangle part of when handling collision within of interactionlistener. class instance has methods need call. how can this?

public function foodinteraction(callback:interactioncallback):void { food.list.remove(body(callback.int1)); universe.space.bodies.remove(body(callback.int1)); // callback.int2 part of class organism, // need access organism , phone call organism33.eat(); }

i have dynamic amount of organism instances. each organism has dynamic number of rectangles. it's first rectangle in interacting. solution can see right have interacting rectangles in separate list along list of organism instances, , access organism via index of rectangle in other list. much faster able access organism via userdata in rectangle body... couldn't extend body because it's final class. please help!

i hate when finding solution seconds after asking it. if else interested in solution:

store instance this: body.userdata.organism = organism;

then access it: callback.int2.userdata.organism.foo();

actionscript-3 collision-detection nape

No comments:

Post a Comment