GLBasic forum

Feature request => 2D => Topic started by: MrTAToad on 2008-Oct-29

Title: Destroying all objects/sounds etc etc
Post by: MrTAToad on 2008-Oct-29
Could do with a proper way of destroying all loaded objects, sprites, music and sfx etc etc - doing this by loading an invalid file is a bit inefficient.
Title: Re: Destroying all objects/sounds etc etc
Post by: Hemlos on 2008-Oct-29
I never had a need for this, but i think this is how its done:

LOADSPRITE "myfile.bmp",0

LOADSPRITE "",0
edit:

Reuse the index's to unload and reload something new in its place.

Title: Re: Destroying all objects/sounds etc etc
Post by: MrTAToad on 2008-Oct-29
Its how I do it - but having to loop through a large number of items is a bit time consuming.  A nice command to do it would be most useful.

In addition, I'm not sure doing a load with an invalid filename actually deletes the sprite/sound etc etc properly.
Title: Re: Destroying all objects/sounds etc etc
Post by: Hemlos on 2008-Oct-29
It does delete it, or at least it USED TO....

im going to test it for you.
brb
Title: Re: Destroying all objects/sounds etc etc
Post by: Hemlos on 2008-Oct-29
This definetly works in windows xp, memory is freed by using LOADSPRITE "",0


And this wont take but a fraction of a second:
Code (glbasic) Select

for i=0 to 10000
loadsprite "",i
x_loadobj "",i
loadsound "",i

next
Title: Re: Destroying all objects/sounds etc etc
Post by: MrTAToad on 2008-Oct-30
I'm not sure about the Mac side - I delete all my objects, change screen size and then re-load, and for some reason two sprites are completely wrong - they end up with a font bitmap  :O
Title: Re: Destroying all objects/sounds etc etc
Post by: Hemlos on 2008-Oct-30
Did you check the index numbers?


Check to see what they are LOADSPRITE "NAME", INDEX

what are your index numbers??
If they are too HIGH ..ie 325656 etc...this might happen
Title: Re: Destroying all objects/sounds etc etc
Post by: MrTAToad on 2008-Oct-30
Oh yes, its the correct sprite size - and the correct filename is loaded.  Just get a totally different image :)
Title: Re: Destroying all objects/sounds etc etc
Post by: Hemlos on 2008-Oct-30
Like i said i ran into this issue before, its due to the indexing numbers.

Post a sample that causes the problem please.