Author Topic: Destroying all objects/sounds etc etc  (Read 4722 times)

MrTAToad

  • Guest
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.
« Last Edit: 2008-Oct-29 by MrTAToad »

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1579
  • Particle Hawk
    • View Profile
Re: Destroying all objects/sounds etc etc
« Reply #1 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.

« Last Edit: 2008-Oct-29 by Hemlos »
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

MrTAToad

  • Guest
Re: Destroying all objects/sounds etc etc
« Reply #2 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.
« Last Edit: 2008-Oct-29 by MrTAToad »

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1579
  • Particle Hawk
    • View Profile
Re: Destroying all objects/sounds etc etc
« Reply #3 on: 2008-Oct-29 »
It does delete it, or at least it USED TO....

im going to test it for you.
brb
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1579
  • Particle Hawk
    • View Profile
Re: Destroying all objects/sounds etc etc
« Reply #4 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
« Last Edit: 2008-Oct-29 by Hemlos »
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

MrTAToad

  • Guest
Re: Destroying all objects/sounds etc etc
« Reply #5 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

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1579
  • Particle Hawk
    • View Profile
Re: Destroying all objects/sounds etc etc
« Reply #6 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
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

MrTAToad

  • Guest
Re: Destroying all objects/sounds etc etc
« Reply #7 on: 2008-Oct-30 »
Oh yes, its the correct sprite size - and the correct filename is loaded.  Just get a totally different image :)

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1579
  • Particle Hawk
    • View Profile
Re: Destroying all objects/sounds etc etc
« Reply #8 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.
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)