dphang/roku-lib

About Spinner

Closed this issue · 1 comments

Hi,
Can you give me an example to begin with your UI Spinner?
I would like to put a great loader during the video loading.

Thank you very much

Hey, unfortunately I'm pretty rusty with BrightScript/Roku stuff, so I'm sorry if this isn't too helpful. But as far as I remember, my RlSpinner is just a rotatable image that spins.

If you're using a roScreen, basically in the event loop you will need to be calling Update(delta) and Draw(screen) in every frame. Delta is basically the time difference between the current frame and last frame; it is used so we get smooth animations.

Because the Roku isn't frame-locked, some frames might take longer or slower to draw at times. We still need the object to be moving (or spinning in this case) at the same speed, so we use delta to move it slower or faster depending on how long the previous frame took to render.

Assuming you already have a roScreen variable named screen, here's an example to continuously draw it. Note, this is mostly pseudocode, so you'll have to fix it up (e.g I can't remember how to get the time in seconds as a decimal).

spinner = RlSpinner("example.png", 500, 500, 500, 500, 0.5)
current = CurrentTimeInSeconds()
while true:
    ' Calculate delta using the time difference, and save the current time.
    time = CurrentTimeInSeconds()
    delta = time - current
    current = time

    ' Update the spinner and draw it
    spinner.Update(delta)
    spinner.Draw(screen)