I'm still getting to grips with AppGameKit and types etc and I have got stuck with deleting a sprite if the animation has finished.
The following functions are called in the main program loop.
The problem is only the latest explosion gets deleted, So if theres more than one explosion happening the earlier ones stop on the last frame and stop on screen.
Any help would be appreciated.
function explosion()
for t = 0 to alive
alive = alive + 1
if alive > 20 then alive = 1
for k = 0 to count
count = count + 1
if count > 30 then count = 1
if GetSpriteExists(bullit[count].id)
if GetSpriteExists(monster[alive].id)
if GetSpriteCollision( (bullit[count].id), (monster[alive].id) ) = 1
deletesprite (bullit[count].id)
fx#= getspritex (monster[alive].id)
fy#= getspritey (monster[alive].id)
deletesprite (monster[alive].id)
debris = debris + 1
if debris > 10 then debris = 1
(explode[debris].id) = createsprite (plode)
setspritescale ((explode[debris].id),.5,.5)
setspritey((explode[debris].id),fy#)
setspritex((explode[debris].id),fx#)
SetSpriteAnimation ( (explode[debris].id), 128, 128, 32 )
PlaySprite ( (explode[debris].id), 30, 0, 1, 32 )
endif
endif
endif
next k
next t
endfunction
function updateexplosion()
for d = 0 to debris
if GetSpriteExists(explode[debris].id)
if getspriteplaying (explode[debris].id) = 0
deletesprite(explode[debris].id)
endif
endif
next d
endfunction