Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
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.

Code

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

-- 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)
end
end

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

Comments

Sign In or Register to comment.