Hi masterq32,
Can u explain exactly how the second method works. A piece of demonsrating code would be great.
In any case thanks again
So, you'll need an array of bmaps, right. Let's say you have 64 bitmaps:
Well, you'll have to load them all, right? Assuming you don't want to spend months typing, you should name them all with a simple namescheme, such as "myanim0.bmp", "myanim1.bmp", etc. so we only have to put the number in there.
Then, we can load them, like this (put this in a function, such as your main-function)
STRING* tmpstr=str_create("#32");
for(i=0; i < 64; i++) {
//stitch the filename together
str_cpy(tmpstr,"myanim");
str_cat(tmpstr,str_for_int(NULL,i));
str_cat(tmpstr,".bmp");
myanimmaps[i] = bmap_create(tmpstr);
}
Sweet, so now you've got it all in memory. All that's left to do is to play it back.
Assuming you're animation is to be played back with 24 frames per second, then that means we have to wait 1/24 of a second after each frame, right? 1/24 = 0.04.
So here we go:
void playanimation() {
char i; //you'll need something bigger than char if you have more than 255 frames
for(i=0; i < 64; i++) {
//Draw the bmap - for instance, via:
draw_quad(myanimmaps[i],nullvector,NULL,NULL,NULL,NULL,100,0);
wait(-0.04); //check wait in the manual to learn why I pass a negative value here
}
}
And that's about it!
You can also use a panel to display it, and set the Panel's bmap-pointer to the actual frame (myanimmaps[i]), if you can't use draw_quad for some reason.
A last word on this - be aware that this way, all your frames are uncompressed in memory at all times. This might lead to an enormous increase in memory consumption. If it is an option, consider using the media_-instruction (and make your animation an actual movie), which streams the video, possibly improving that situation.
Of course, if its a short animation with few frames, you can do it this way.
Consider at least purging the bmaps if you don't need them, though (see bmap_purge in the manual to learn how to do this)