# How to stop spawning sprites ??

0 favourites
• 7 posts
From the Asset Store
Build your map with these isometric objects and terrains
• 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 !

#### Tagged:

• 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.

For example

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.

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• Hey!

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...

Cheers!

• 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.

Cheers.

• 7 posts