Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
event listener self reference — Gideros Forum

event listener self reference

I know this has been asked a lot and I've seen several answers but I cannot seem to apply it to my scenario. How can I get to my 'self' of the class where I have an event listener. Here is what I have.


function launcher:init()
self.mouseJoint = nil
self.ground = world:createBody({})
self.grabber_display [sprite]
self.grabber_body [box2d body]

-- create a mouse joint on mouse down
function launcher:grabber_display_onMouseDown(event)
if self:hitTestPoint(event.x, event.y) then
local jointDef = b2.createMouseJointDef(self.ground, self.grabber_body, event.x, event.y, 100000)
self.mouseJoint = world:createJoint(jointDef)

self.grabber_display:addEventListener(Event.MOUSE_DOWN, self.grabber_display_onMouseDown, self.grabber_display)


Inside the launcher:grabber_display_onMouseDown event is where self.ground & self.grabber_body & self.mouseJoint are all nil


Sign In or Register to comment.