Spawner Help

Get help using Construct 2

Post » Sat Feb 13, 2016 8:07 pm

I made some spawners that spawn enemies when they come onto the screen.

I want to make it so they only spawn if the enemy that they just spawned no longer exists when the spawner comes back onto screen.
Nothing that i have tried has worked, hoping someone can point me in the right direction.


example
[*]https://www.scirra.com/arcade/other-games/spawner-example-5538

capx
[*]https://games.scirra.net/games/5538/files/game.capx
B
4
Posts: 6
Reputation: 216

Post » Sat Feb 13, 2016 8:20 pm

You will need to "bind" the enemy to the spawner.

Spawner gets a booleon variable called "enemy_in_game"

The enemy gets a variable called "spawnerUID"

On create the enemy sets "spawnerUID" to the spawners UID and the spawner sets "enemy in game" to true

On enemy destroy pick the spawner with the "spawnersUID" and set "enemy in game" to false.

if "enemy in game" is false and the spawner comes onto screen--->spawn enemy
B
7
S
2
Posts: 56
Reputation: 583

Post » Sat Feb 13, 2016 10:52 pm

Like this?
[*]http://i.imgur.com/LPTq4af.png
Doing that made only one of the spawners work, and it would spawn an enemy as soon as one was destroyed (going off screen).

I only want the spawners to spawn if they enemy they spawned no longer exists and if the spawner has exited and re-entered the screen.
B
4
Posts: 6
Reputation: 216

Post » Sun Feb 14, 2016 1:49 am

Ok it just needs some tweaking.
In the first event you dont pick a specific spawner so construct picks all of them.
So it will set ALL spawners to "enemyingame" true.

In the destroyed event you just set 1 spawner to "enemyingame" =false.

Thats why just one works.
You need to tell the event on which spawner the enemy has spawned.


The second problem is a bit more tricky.

You need to tell the spawner that it isent on screen to "reload" it.
At least thats what i understand you would like to have.
So i guess you will need another variable calles "readytospawn" or something like that.

If the spawner spawns "readytospawn" set to false.

If the spawner is NOT on screen set "readytospawn" to true.

if "readytospawn" =true and "enemyingame" = false and spawner on screen then spawn new enemy.
B
7
S
2
Posts: 56
Reputation: 583

Post » Sun Feb 14, 2016 1:51 am

I figured it out.

Here's how i did it in case anyone is looking to do something similar.
[*]http://i.imgur.com/xdLA2fk.png
B
4
Posts: 6
Reputation: 216

Post » Sun Feb 14, 2016 1:54 am

looks like you started replying right as i figured it out. thanks for the help!
B
4
Posts: 6
Reputation: 216

Post » Sun Feb 14, 2016 2:03 am

Looks fine.
With the counter variable you could even bind more than 1 enemy to a spawner.

There are some small things that shouldent be necessary like storing the spawnersUID in itself or the double loop but who cares if it works. :)
B
7
S
2
Posts: 56
Reputation: 583


Return to How do I....?

Who is online

Users browsing this forum: megatronx, RetrocadeMedia, totoe and 1 guest