I am building a tower defense game, in which i have few waves of enemies with certain specific number of enemies in a wave. i added the spawning function but i dont know how to make it stop, i added a separate variable for enemy counts. i am still learning so please explain !
Can you show us your events?
If it was mine.. I would go for an array to store the amount of enemies for each wave.
Wave 1 = 10
Wave 2 = 20
Wave 3 = 27
Create a variable to store the array index value (the wave number)
And now, create a for using the index value to get the wave amount
So every time it calls this functions it will look to the array to create the right amount of enemies.
Don`t forget to increment the index, otherwise it will always create the same amount of enemies for all waves.
Develop games in your browser. Powerful, performant & highly capable.
drive.google.com/file/d/0BybBQ5tkpPMkTnhHc2VvNDNqTjA3djFteFpEeTcwazBzQjBn/view can you check it out and explain please.
Check this file.
I used a string to store the sizes of the waves, cause it's faster, but you should use an array. Also, the time between waves is constant, you should make it variable, in that case use the same array to inform the intervals... Like wavesArray = [[wave 0 size,wave 0 interval],[wave 1 size,wave 1 interval],[wave n size,wave n interval]]
In case you never used arrays, you can access tyhe info in an array with wavesArray.At(x,y). So, you would use wavesArray.At(currentWave,0) for the size and wavesArray.At(currentWave,1) for the next interval.
Hope this helps...
Thank you got it !! :-)
Also if size and interval can be calculated with a function you can just drop the array stuff and use a formula instead.
For instance. Let's say your wave sizes are (5, 10, 15, 20, 25), there's a clear pattern there.
size = 5 + currentWave * 5
So you can just use the formula instead of writing a giant array which can be calculated easily.