Destroying all objects/sounds etc etc

Previous topic - Next topic

MrTAToad

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.

Hemlos

#1
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.

Bing ChatGpt is pretty smart :O

MrTAToad

#2
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.

Hemlos

It does delete it, or at least it USED TO....

im going to test it for you.
brb
Bing ChatGpt is pretty smart :O

Hemlos

#4
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
Bing ChatGpt is pretty smart :O

MrTAToad

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

Hemlos

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
Bing ChatGpt is pretty smart :O

MrTAToad

Oh yes, its the correct sprite size - and the correct filename is loaded.  Just get a totally different image :)

Hemlos

Like i said i ran into this issue before, its due to the indexing numbers.

Post a sample that causes the problem please.
Bing ChatGpt is pretty smart :O