Sprites created from a GIF (Release Announcements)

by Hughze, Friday, February 21, 2014, 06:59 (1391 days ago)

Why won't my sprite created from a GIF animate?

Sprites created from a GIF

by Jim ⌂ @, Russell, KY, Friday, February 21, 2014, 16:31 (1390 days ago) @ Hughze

You can create a sprite from a GIF but an animated GIF is not supported. You could create a sprite for each frame and use your BASIC code to flip through them. I will think of an example.

Jim

Sprites created from a GIF

by Jim ⌂ @, Russell, KY, Friday, February 21, 2014, 17:32 (1390 days ago) @ Hughze

here is an example - load the sprites however you want

# animatebox - simnple frame by brame sprite animation
# j.m.reneau 2014-02-21

clg
spritedim 4
global animateframe
animateframe = 0

color black
spritepoly 0, {0,0,100,0,100,100,0,100}
color darkred
spritepoly 1, {0,0,50,0, 50,40, 40,40, 40,60, 60,60, 60,40, 50,40, 50,0, 100,0, 100,100, 0,100}
color darkgreen
spritepoly 2, {0,0,50,0, 50,25, 25,25, 25,75, 75,75, 75,25, 50,25, 50,0, 100,0, 100,100, 0,100}
color darkblue
spritepoly 3, {0,0,50,0, 50,10, 10,10, 10,90, 90,90, 90,10, 50,10, 50,0, 100,0, 100,100, 0,100}


while true
call movebox(mousex, mousey)
call animatebox()
pause .02
end while


subroutine movebox(x,y)
# if we move one of then - move all of them

for t = 0 to 3
spriteplace t,x,y
next t
end subroutine

subroutine animatebox()
# every 200 ms do next frame
# show sprite 0, 1, 2, 3, 2, 1 then repeat
# animate frame just counts up from 0 now many frames we have done
if msec>=animateframe * 200 then
# for this frams which sprite should we show
sp = animateframe % 6
if sp > 3 then sp = 6-sp
# show it
spriteshow sp
# hide the others
for t = 0 to 3
if sp <> t then spritehide t
next t
animateframe++
endif
end subroutine

Sprites created from a GIF

by Hughze, Saturday, February 22, 2014, 04:49 (1390 days ago) @ Jim

Hello Jim,

Your example was very helpful. Thank you. Hughze.

RSS Feed of thread
powered by my little forum