Last active
April 24, 2019 23:00
-
-
Save acotilla91/fdb4fd70e914d3df74408c7fdfcc65ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub init() | |
m.animator = CreateObject("roSGNode", "Timer") | |
m.animator.ObserveField("fire", "displayNextFrame") | |
m.animator.repeat = true | |
m.frames = [] | |
m.frameIndex = -1 | |
m.poster = invalid | |
end sub | |
function start(frames as Object, fps as Float, poster as Object) | |
m.frames = frames | |
m.poster = poster | |
m.animator.duration = fps | |
m.animator.control = "start" | |
end function | |
function finish() | |
m.animator.control = "stop" | |
' Restore first frame | |
if m.frames.count() > 0 m.poster.uri = m.frames[0] | |
m.frameIndex = -1 | |
m.frames = [] | |
m.poster = invalid | |
end function | |
sub displayNextFrame() | |
m.frameIndex++ | |
if m.frameIndex >= m.frames.count() | |
m.frameIndex = 0 | |
end if | |
m.poster.uri = m.frames[m.frameIndex] | |
end sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment