I use a code similiar to the following:
action play_snd() {
SOUND* snd = snd_create(my.string1);
int x = 0;
var sound_handle;
if (snd != NULL) {
sound_handle = ent_playloop (my, snd, 100);
}
}
The problem is that the sound that is created by snd_create isn't removed from memory when a new level is loaded.
I'm currently setting a variable "levelLoaded" when changing the level, so that the code looks something like this:
action play_snd() {
ENTITY* thisEnt = my;
my = NULL;
SOUND* snd = snd_create(thisEnt.string1);
int x = 0;
var sound_handle;
if (snd != NULL) {
sound_handle = ent_playloop (thisEnt, snd, 100);
while(levelLoaded == 1) { wait(1); }
snd_stop(sound_handle);
ptr_remove(snd);
}
}
Is there a better way to do this?
Regards,
Pegamode.