reset sprite order after deleteallsprites ?

Started by micky4fun, December 13, 2009, 03:29:45 PM

Previous topic - Next topic

micky4fun

Hi Kevin

just a quick one , is it possible to reset the sprite order created once a deleteallsprites command

ie ,

if i use say 20 sprites , then deleteallsprites
then create a new sprite with newsprite=getfreesprite() command , can i make this sprite 1 and not last sprite that was deleted

dim s(20)
for a =1 to 20
s(a)=getfreesprite()
createsprite s(a)
next a
deleteallsprites
s=getfreesprite()
print s
sync

waitkey


this returns 20
but i want to start at 1 again , is this possible ?

thanks
mick

kevin

Quotethen create a new sprite with newsprite=getfreesprite() command , can i make this sprite 1 and not last sprite that was deleted

   Nope.       When we use dynamic creation (getFreespirte, NewSprite()), the sprite number should be irrelevant to us.  In other words at no point should we hard code something to assume we known what the sprite/image/shape etc etc number is.


micky4fun

Thanks , kevin

thought this would be the answer ,

mick :)

BlinkOk

if you use the array element number as your key then the sprite number is irrelevant

micky4fun

Hi BlinkOk

didnt really have a problem , just wanted code/program to be a bit more tidy , as left some sprites that was not needed
the problem arose when using the drawspriterange command

ie , drawspriterange  car(1).sprite,car(4).sprite
so cars 1 to 4 where drawn first off all , but when using deleteallsprites
then setting up sprites again , car(1).sprite could for say sake be sprite 20 and car(4).sprite could be sprite 5
if you get my meaning , but i have got pass this now anyway , but just wanted to know if there was such away of resetting them
but i know it makes no sense having that command now ,

thanks
mick :)