Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Problem with Timer? — Gideros Forum

Problem with Timer?

test29test29 Member
edited June 2016 in General questions
Why I can't call function from Timer function:
scene = gideros.class(Sprite)
 
function scene:init(t)
 
    timer = Timer.new(1000)
    timer:addEventListener(Event.TIMER, self.Job)
    timer:start()
 
end
 
function scene:Job()
 
...
 
    if something == 0 then
        self:NextFunction()  -- this line gets error: attempt to call method 'NextFunction' (a nil value)
    end
 
end
 
function scene:NextFunction()
 
end
How to call function from inside Timer function (like in the example above)?

Comments

  • hgy29hgy29 Maintainer
    Accepted Answer
    @test29,
    add self in your event listener registration call:
    timer:addEventListener(Event.TIMER, self.Job, self)

    Likes: antix

    +1 -1 (+1 / -0 )Share on Facebook
  • test29test29 Member
    Thank you!!!
Sign In or Register to comment.