BradC
Binge Watcher
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2014
05:10 PM
how to change animation on animated sprite?
Is there a way to change the animation in an animated sprite?
I can change it to a region containing a bitmap, but can't figure out how to change the animation and have it play properly.
It's fairly easy to just remove the sprite and create a new one with a new animation, but that's a hack, and seems a lot less efficient than just changing the animation on an existing sprite.
thanks.
I can change it to a region containing a bitmap, but can't figure out how to change the animation and have it play properly.
It's fairly easy to just remove the sprite and create a new one with a new animation, but that's a hack, and seems a lot less efficient than just changing the animation on an existing sprite.
thanks.
♦MiniGolf♦HangMan♦Brain Puck♦Retro Tennis♦BORK♦FLIP♦Pathogen♦Pathogen 2♦Shut the Box♦Birdie♦Logic♦Dots♦Pool♦küglo♦Bubble Wrap♦Trivia Channel♦Mancala♦Air Hockey♦Weather♦CAMERA♦Your Photos Screensaver♦Desert Beauty Screensaver♦Wild Lakes Screensaver♦
10 REPLIES 10

NewManLiving
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2014
06:41 PM
Re: how to change animation on animated sprite?
What do you mean by sprite. Are you talking about a sprite created with
The compositor? Or are you talking about a sprite meaning a bitmap
The compositor can take an array of regions and animate them
This is how I do it most of the time for things like cursors, most
Recently a flying dove in my own application. You can also experiment
With the changeallregions if your adventurous. As
For a sprite meaning just a bitmap I'm not quite
Sure what you are trying to accomplish
The compositor? Or are you talking about a sprite meaning a bitmap
The compositor can take an array of regions and animate them
This is how I do it most of the time for things like cursors, most
Recently a flying dove in my own application. You can also experiment
With the changeallregions if your adventurous. As
For a sprite meaning just a bitmap I'm not quite
Sure what you are trying to accomplish
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )

NewManLiving
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2014
07:08 PM
Re: how to change animation on animated sprite
If I am guessing correctly. You can create a bitmap the complete size of all the frames in your animation
So if your frame size was say 100 * 200 and you have 5 frames of animation you create an empty bitmap
Of width 100 x 5, 200. Load your resource for each frame and draw object into the empty bitmap offsetting
The x pos by 100 each time. This would create a contiguous strip for you to animate. Next you create a region
The size of a single frame 0,0, 100, 200. Then all you have to do is offset the region in the x pos by 100 to animate
If you set wrap to true it will wrap around. Now if you already have a contiguous bitmap. Then you can skip step one
And just build a region the size of one frame and offset it to move through the frames
So if your frame size was say 100 * 200 and you have 5 frames of animation you create an empty bitmap
Of width 100 x 5, 200. Load your resource for each frame and draw object into the empty bitmap offsetting
The x pos by 100 each time. This would create a contiguous strip for you to animate. Next you create a region
The size of a single frame 0,0, 100, 200. Then all you have to do is offset the region in the x pos by 100 to animate
If you set wrap to true it will wrap around. Now if you already have a contiguous bitmap. Then you can skip step one
And just build a region the size of one frame and offset it to move through the frames
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2014
07:16 PM
Re: how to change animation on animated sprite?
It's actually much more straightforward than that. You just need to create an array of regions that make up the frames of the animation, then create a sprite with roCompositor.NewAnimatedSprite(). You'd then call roCompositor.AnimationTick() to automatically advance any animated sprites in the compositor. The duration you pass to AnimationTick() uses the value you set on the individual frame regions via roRegion.SetTime() to determine which frame to advance to. If you don't set a time on the region, then AnimationTick() will always advance to the next frame.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
BradC
Binge Watcher
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2014
08:07 PM
Re: how to change animation on animated sprite?
apologies for not being clear.
if I've defined 2 animation sets in the sprite map, how do I switch between them in a given animated sprite? Or is this not currently possible?
if I've defined 2 animation sets in the sprite map, how do I switch between them in a given animated sprite? Or is this not currently possible?
♦MiniGolf♦HangMan♦Brain Puck♦Retro Tennis♦BORK♦FLIP♦Pathogen♦Pathogen 2♦Shut the Box♦Birdie♦Logic♦Dots♦Pool♦küglo♦Bubble Wrap♦Trivia Channel♦Mancala♦Air Hockey♦Weather♦CAMERA♦Your Photos Screensaver♦Desert Beauty Screensaver♦Wild Lakes Screensaver♦

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2014
08:18 PM
Re: how to change animation on animated sprite?
"BradC" wrote:
apologies for not being clear.
if I've defined 2 animation sets in the sprite map, how do I switch between them in a given animated sprite? Or is this not currently possible?
By "2 animation sets" do you mean like one set of a bird flying to the left and another of a bird flying to the right? If that's the case, then I think you'd need two separate sprites that you hide or show depending on which animation you want to display.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)

NewManLiving
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2014
08:26 PM
Re: how to change animation on animated sprite?
"TheEndless" wrote:
It's actually much more straightforward than that .
Yes I alluded to that in my first post but I was not sure if he was using a sprite
Meaning a bitmap. You recall that some people use the term sprite meaning
Bitmap. So I came back with the second response. But you know that I am
A big fan of the compositor and use animation tick quite often
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
BradC
Binge Watcher
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2014
08:34 PM
Re: how to change animation on animated sprite?
"TheEndless" wrote:
By "2 animation sets" do you mean like one set of a bird flying to the left and another of a bird flying to the right? If that's the case, then I think you'd need two separate sprites that you hide or show depending on which animation you want to display.
Yep, that's exactly my question... is there a way to switch animations on an animated sprite, or does the sprite have to be destroyed and recreated (or hidden if you have extra CPU and memory available to play with)
♦MiniGolf♦HangMan♦Brain Puck♦Retro Tennis♦BORK♦FLIP♦Pathogen♦Pathogen 2♦Shut the Box♦Birdie♦Logic♦Dots♦Pool♦küglo♦Bubble Wrap♦Trivia Channel♦Mancala♦Air Hockey♦Weather♦CAMERA♦Your Photos Screensaver♦Desert Beauty Screensaver♦Wild Lakes Screensaver♦

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2014
09:03 PM
Re: how to change animation on animated sprite?
"BradC" wrote:"TheEndless" wrote:
By "2 animation sets" do you mean like one set of a bird flying to the left and another of a bird flying to the right? If that's the case, then I think you'd need two separate sprites that you hide or show depending on which animation you want to display.
Yep, that's exactly my question... is there a way to switch animations on an animated sprite, or does the sprite have to be destroyed and recreated (or hidden if you have extra CPU and memory available to play with)
The sprite has a SetRegion method, that would allow you to reset the region on a non-animated sprite. It may accept an array to do the same with an animated sprite, but I've never tried that.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2014
09:52 PM
Re: how to change animation on animated sprite?
"BradC" wrote:
Yep, that's exactly my question... is there a way to switch animations on an animated sprite, or does the sprite have to be destroyed and recreated (or hidden if you have extra CPU and memory available to play with)
There is this mysterious ChangeMatchingRegions() method, about which i asked the other day - it might be related. Or not :roll: