How do I toggle objects to spawn on 1 keyboard button press?

Get help using Construct 2

Post » Wed Aug 27, 2014 12:14 am

Hi, so this thing I'm working on is intended to basically toggle whether or not something is activated or not upon a press of the spacebar. Basically I have an item that sits in the room and I want it to be so that when I press spacebar it toggles between that item and a different sprite object. I can get it to go one way fine by saying "On Space pressed Spawn Plant && Destroy Pod" but I would like it to be a togglable, so that I can press space and it will either destroy the Pod and spawn the Plant, or vice versa.

I'm just really struggling with the syntax of this and am not really sure how to structure my events to do this. I played with instance variables but none of them really accomplished what I wanted to tell them to do.

Thanks.
B
3
Posts: 3
Reputation: 362

Post » Wed Aug 27, 2014 12:52 am

If there is only one at a time, you can check Plant.Count to see if a Plant is created or not. Use Else for the second case.

if Plant.Count = 1 -> Spawn Pod, Destroy Plant
Else Spawn Plant, Destroy Pod

A Global variable would also work, not an Instance variable.
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 38 guests