Stop and remove all sounds added to an object

edited December 2011 in Help request
Hello,
I have some objects in my game that, when killed, are disabled (orxObject_Enable( object, orxFALSE )) to avoid the overhead of deleting and recreating the object.

The problem is when the object is disabled all sounds added to it never end. Is there a way to stop and remove all those sounds?

Comments

  • edited December 2011
    Hi Peso,

    You should be able to stop all the sounds on your object with a call to orxSoundPointer_Stop(), however they won't get removed.

    I can add a orxSoundPointer_RemoveAllSound() tonight for that purpose.
  • edited December 2011
    iarwain wrote:
    I can add a orxSoundPointer_RemoveAllSound() tonight for that purpose.
    Hi iarwain, that would be really good. Thanks.
  • edited December 2011
    It's in.

    Out of curiosity, were you often deleting/creating a lot of objects and did it become a performance issue?
  • edited December 2011
    Well, I didn't even try it. I went directly to the disabling strategy. But I'm having a little glitch when I first create some specific objects. I think it is due to the texture loading, but I didn't look into it yet.
  • edited December 2011
    Ah yes, you might want to preload some of your assets, especially shaders, textures and sounds.

    For shaders and sounds, simply call the CreateFromConfig() with the appropriate name and whenever you want to unload the asset, you can call Delete() on them.

    For textures, call CreateFromFile() to load them and Delete() to unload them.

    You can easily find the names in your config data or add explicit lists of load/unload per level for example, or whichever scheme suits your game.

    For Drops, I preload all the sound samples while the splash screen is displayed to prevent any glitch later. The source's available if you wanted an example.
  • edited December 2011
    Oh and yes, there's no real memory allocation when you create objects most of the time as we simply reuse items from a memory bank (ie. pool). However, resources like textures might get re-loaded if there are no more references on them (hence the advantage of preloading).
  • edited December 2011
    Late Thanks!
  • edited December 2011
    You're welcome!
Sign In or Register to comment.