I have a area in my game and i want an enemy to spawn after 30 seconds, does anyone know how i could do this?
I think probably
on enter do
wait 30 then
call "eventName"
end
end
then in eventName somewhere you can add your enemy
Thank you very much, Its working now!
I did try the script above and found that it doesn't work? Or perhaps just doesn't work anymore? After checking my script multiple times, I determined that there wasn't anything wrong with the example given one my end, but a simpler way to do this is as follows:
on enter do
wait 15 then
tell 18,6 to
swap "enemy"
end
end
end
TELL is telling you what tile area the 'enemy' will appear in. It works every time and does not duplicate. So if you wait 15 seconds, and then another 15 seconds, it will still only spawn one enemy.
in order to spawn multiple, you'll need to do the following:
on enter do
wait 15 then
tell 18,6 to
swap "enemy"
wait 0.5 then
tell 4,13 to
swap "enemy2"
end
end
end
end
end
and of course, modify the numbers, or sprite names accordingly.
Just to check why it wasn't working, did you add the tell/swap code to a custom event handler as well, eg:
on enter do
wait 30 then
call "spawnEnemy"
end
end
on spawnEnemy do
tell 18,6 to
swap "enemy"
end
end
If you're spawning multiples though, you should be able to separate out the different wait sections, for example:
on enter do
wait 15 then
tell 18,6 to
swap "enemy"
end
end
wait 15.5 then
tell 4,13 to
swap "enemy2"
end
end
end
The first wait
command will do its thing in 15 seconds, but meanwhile the code will carry on, and set up the second wait
command to do its thing in 15.5 seconds. The end result should be the same, but it might make it easier if you need to shuffle code around, or keep things readable.