krh5150
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2013
02:01 PM
Loading Animation Example
Does anyone have an example of a loading animation for a roImageCanvas?
Thanks,
Kevin
Thanks,
Kevin
3 REPLIES 3

RokuJoel
Binge Watcher
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2013
03:44 PM
Re: Loading Animation Example
Here's something quick off the top of my head, since I have done it before:
find an animated "loading" gif online, and break it into separate image files, put them in a folder under your images folder like images/gfx
Create a set of objects, one for each image. Here, off the top of my head is about how I would do it:
within whatever function is downloading and parsing data, you want to periodically call updateAnimation. You'll have to pass the screen and animation object around, or you could make them both globals, remove the parameters from the function call and then you could just call updateAnimation() from anywhere to draw the next frame.
- Joel
find an animated "loading" gif online, and break it into separate image files, put them in a folder under your images folder like images/gfx
Create a set of objects, one for each image. Here, off the top of my head is about how I would do it:
function setupAnimation() as object
m.animation=[{url:"pkg:/images/gfx/frame0.png",compositionMode:"Source_Over",targetrect:{x:640,y:360,w:32,h:32}}
{url:"pkg:/images/gfx/frame1.png",compositionMode:"Source_Over",targetrect:{x:640,y:360,w:32,h:32}}
{url:"pkg:/images/gfx/frame2.png",compositionMode:"Source_Over",targetrect;{x:640,y:360,w:32,h:32}}
{url:"pkg:/images/gfx/frame3.png",compositionMode:"Source_Over",targetrect;{x:640,y:360,w:32,h:32}}
{url:"pkg:/images/gfx/frame4.png",compositionMode:"Source_Over",targetrect;{x:640,y:360,w:32,h:32}}
{url:"pkg:/images/gfx/frame5.png",compositionMode:"Source_Over",targetrect;{x:640,y:360,w:32,h:32}}]
m.animpointer=0
end function
function updateAnimation(screen as object, animation as object)
screen.setlayer(3,[animation[m.animpointer]])
m.animpointer=m.animpointer+1
end function
within whatever function is downloading and parsing data, you want to periodically call updateAnimation. You'll have to pass the screen and animation object around, or you could make them both globals, remove the parameters from the function call and then you could just call updateAnimation() from anywhere to draw the next frame.
- Joel

RokuMarkn
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2013
04:46 PM
Re: Loading Animation Example
You probably also want to wrap m.animpointer back to zero when it reaches animation.count().
--Mark
--Mark

RokuJoel
Binge Watcher
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2013
03:29 PM
Re: Loading Animation Example
:oops: