It looks like you're new here. If you want to get involved, click one of these buttons!
Scene1 = gideros.class(Sprite) function Scene1:init() self:addEventListener("enterBegin", self.onTransitionInBegin, self) self:addEventListener("enterEnd", self.onTransitionInEnd, self) self:addEventListener("exitBegin", self.onTransitionOutBegin, self) self:addEventListener("exitEnd", self.onTransitionOutEnd, self) end function Scene1:onTransitionInBegin() print("scene1 - enter begin") createContainers(self) local lightSwitch = LightSwitch.new(160, 160, layerMG) end function Scene1:onTransitionInEnd() print("scene1 - enter end") local function lightSwitchTouch(button, event) if lightSwitch:hitTestPoint(event.x, event.y) then sceneManager:changeScene('scene2', 2, SceneManager.flipWithShade, easing.inOutQuadratic) lightSwitch:removeEventListener(Event.MOUSE_UP, lightSwitchTouch, lightSwitch) end end lightSwitch:addEventListener(Event.MOUSE_UP, lightSwitchTouch, lightSwitch) end function Scene1:onTransitionOutBegin() print("scene1 - exit begin") end function Scene1:onTransitionOutEnd() print("scene1 - exit end") end |
Comments
But you can make it act as if it was object-oriented, pretty much like in javascript.
To me, the most important thing to know when dealing with classes/objects is lua is the following equivalence (notice the use of dot or colon depending on the construct) :
Likes: Holonist