Im trying to create a series sequence classes that I can use to periodicaly take control of the screen and perform some type of animation or other action, sort of like a cut scene.
I have a timer on my main() function in main.lua which executes as expected. When I tried to create a timer inside this sequence class it does not behave as expected. Instead of firing multiple times, it only fires once.
I also tried using the onComplete callback method for the transition.to function and did not see expected results as well. It fired the onComplete function right away even though there was a 5500 ms delay on the transition. I will post examples of both below
[code]
display.setStatusBar( display.HiddenStatusBar )
–example 1
SequenceResetLevel = {}
SequenceResetLevel.__index = SequenceResetLevel
function SequenceResetLevel:new (i)
local o = {_i = i}
setmetatable(o, self)
return o
end
function SequenceResetLevel:fadeOut()
print “print me 100 times”
end
function SequenceResetLevel:exec()
– this timer should exec fadeOut 100 times ever 100 ms
– but it only executes once
timer2 = timer.performWithDelay(100, self:fadeOut(), 100);
end
sequence1 = SequenceResetLevel:new();
sequence1:exec();
– example 2
SequenceFade = {}
SequenceFade.__index = SequenceFade
function SequenceFade:new (i)
local o = {_i = i}
setmetatable(o, self)
return o
end
function SequenceFade:fadeOut()
print “print me when screen = red”
end
function SequenceFade:exec()
fade = display.newRect( 0, 0, 480, 920 )
fade:setFillColor( 255, 0, 0 )
fade.alpha = 0;
– this transition should exec fadeOut when it is complete in 5500 ms
– but it exec’s that function immediately
test = transition.to( fade, { time=5500, alpha=1, onComplete=self:fadeOut() } )
end
sequence2 = SequenceFade:exec();
[/code] [import]uid: 128290 topic_id: 22081 reply_id: 322081[/import]