Hi guys,
Nice new forum! It's been a while...
So, still hacking away at my game but I think I'm doing something shifty. I've gotten into a bad habit of wrapping my MovieClip animations into a timer so I can do something after the animation finishes. Ew right?
I have a feeling I should be using an event trigger to tell me that the animation is finished and I can go ahead with another piece of code or function. Try as I might I'm making a mangled mess of it. Any tips? This is the bad me:
function GameScene:myWeirdnessFunction()
timer1 = Timer.new(2000, 1)
timer1:addEventListener(Event.TIMER, function()
-- My animation.
mc1 = MovieClip.new{
{1, 200, PLAYER, {y = {PLAYER:getY(), height/2, "linear"}}}
}
self:addChild(mc1)
mc1:play()
end, self)
timer1:start()
end |
Pretty gross right? If the device is slow, things would get weird fast with this approach. Especially if the madness propagates and I start using it everywhere...
So, I'm guessing I need to do something along the lines of:
self:addEventListener(Event.SOME_EVENT_TYPE, function() -- Where self is the game scene presumably.
-- My animation.
mc1 = MovieClip.new{
{1, 200, PLAYER, {y = {PLAYER:getY(), height/2, "linear"}}}
}
self:addChild(mc1)
mc1:play()
end, self) |
Then I hook into that somehow to fire off the next function...
I feel like I'm close, but maybe I'm way off.
Maybe mc1:addEventListener(args)?
Comments
Likes: antix, totebo, Apollo14, Astirian
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!