It looks like you're new here. If you want to get involved, click one of these buttons!
Tutorial = Core.class(Sprite) function Tutorial:init() self.tuts = tutorialGFX self:close() end function Tutorial:close() self:dispatchEvent(Event.new("onClose")) end Game = Core.class(Sprite) function Game:init() local tutorial = Tutorial.new() self:addChild(tutorial) tutorial:addEventListener("onClose",function() print("CLOSED") end) end |
Comments
So i think in your code, maybe when you init Tutorial via Tutorial.new(), it does not have eventListener. In my version, put it before call close, you can dispatchEvent as normal.
Likes: ar2rsawseen
Work but is not exactly what i need...
I dont want to addEventListner inside The tutorial class...and i don t want to call Close outside The class....
Tutorial is a fullscreen tutorial that explain The game and is called in different scenes of The game so, outside The tutorial class, i have to intercept when The tutorial finish and the event "onClose" si dispatched because i have to do different things depending on where i am.
https://play.google.com/store/apps/developer?id=Arcadia Solutions
So basically what you posted in your first post, will work, when you call tutorial:close somewhere in your code
Likes: vitalitymobile
https://play.google.com/store/apps/developer?id=Arcadia Solutions
So i think your class should be like this:
Likes: arcadia
There should be some other action or input from user, that would dispatch the even only after you attached the event listener
Likes: arcadia, vitalitymobile
Thanks both
Likes: vitalitymobile
https://play.google.com/store/apps/developer?id=Arcadia Solutions