Restricting one instance of a sprite on screen not working

Just started using Construct 2? Post your questions here

Post » Sat Jan 10, 2015 9:14 pm

I'm trying to make it where when a sprite is spawned, only that one version of the sprite can be on-screen until it is destroyed. Kind of like having a missile, but prevents the player from spamming missiles and only allows for one missile to be on-screen at once.

In this instance I'm specifically attempting making the sprite appear when the button is held down, and vanish when the button is released.

This is my attempt:

Image

I figured just make a check to only allow a button press when the sprite is off-screen, but oddly that didn't work. Then I tried to make an instance variable that would boolean a value to to true when created, and also would only allow a spawning if the boolean was false. Also didn't work. After the same failure occurred after a number variable, it became clear to me that there is something that I'm just not doing right.
B
20
S
5
Posts: 108
Reputation: 1,473

Post » Sat Jan 10, 2015 10:11 pm

At a quick look, make spawned a global variable. And put 84 a subevent of 85 (reverse them) and obviously move the actions to 84.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sat Jan 10, 2015 10:23 pm

Simply put sprite.count then restrict them:
Image

Just change the keyboard setup with gamepad setup.
ImageImage
B
101
S
45
G
22
Posts: 772
Reputation: 21,468

Post » Sat Jan 10, 2015 10:53 pm

That's exactly what I needed! Thanks!
B
20
S
5
Posts: 108
Reputation: 1,473


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests