Okies
When a new enemy is generated in my game I would like it to play a different sound effect depending on which type of enemy is generated.
In the game init function I preload the sounds as such
[lua]spawn1_sound = audio.loadSound(“sfx/spawn1.wav”)
spawn2_sound = audio.loadSound(“sfx/spawn2.wav”)
spawn3_sound = audio.loadSound(“sfx/spawn3.wav”)
spawn4_sound = audio.loadSound(“sfx/spawn4.wav”)[/lua]
And then when I spawn an enemy I’ve got the following code…
[lua]for i=1,maxEnemies do
if (enemies[i] == nil) and (newenemy==1) then
local newestEnemy = create_enemy()
entities:insert(newestEnemy)
enemies[i] = newestEnemy
local thisspawnsound = (“spawn” … enemies[i].spec … “_sound”)
print(thisspawnsound);
audio.play (thisspawnsound)
end
end[/lua]
The problem is that no sound is played.
I’ve outputted the ‘thisspawnsound’ variable to the console to check it is OK and it is but nothing happens sound wise.
If I change the play command to play a specific sound it works with no problems at all.
e.g.
[lua]audio.play(spawn1_sound)[/lua]
Anyone got any ideas where I’m going wrong?
Cheers
[import]uid: 7841 topic_id: 14474 reply_id: 314474[/import]