Skip to content

Instantly share code, notes, and snippets.

@acotilla91
Last active April 24, 2019 23:00
Show Gist options
  • Save acotilla91/fdb4fd70e914d3df74408c7fdfcc65ad to your computer and use it in GitHub Desktop.
Save acotilla91/fdb4fd70e914d3df74408c7fdfcc65ad to your computer and use it in GitHub Desktop.
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