spawning instances

Get help using Construct 2

Post » Wed Oct 02, 2013 7:54 pm

thanks in advance!

Im stumped on why this wont work...
I want the player to only be able to spawn a new instance when there isn't not one already on the screen...the object has to leave the layout before a new one can be spawned...

I have an event that looks like this with 2 conditions and one action:

keyboard - on space is pressed | Spawnerobject | Spawn Sprite1
Sprite1 - X is on-screen



its simple enough but isn't working.
any ideas?
thanks
B
8
S
3
G
1
Posts: 87
Reputation: 1,493

Post » Wed Oct 02, 2013 8:17 pm

Is on-screen
True if any part of the object's bounding box is within the screen area. This is not affected by the object's visibility or opacity.

So if this isn't working this condition isn't met.
Maybe destroy your original sprite on start of layout.
Maybe change the bounding box.


But you are not saying what isn't working, and what unexpected things are happening, so I could be wrong.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Oct 03, 2013 4:24 am

@LittleStain

well, im trying to have it so that I when the object is on the screen, the player cant spawn more objects...so there will only be one object on the screen at a time...

the project file is here:
https://www.dropbox.com/s/dab5terulvojqq9/spawner.capx

im not sure why this simple logic isn't working still....anyone?
thanks
Dan
B
8
S
3
G
1
Posts: 87
Reputation: 1,493

Post » Thu Oct 03, 2013 4:52 am

try this:

Condition:
-On any click
--Sprite2.count <= 0
Action:
-Spawn Sprite2

Condition:
-Sprite2 is on-screen (invert)
Action:
-Destroy Sprite2
B
17
S
8
G
4
Posts: 93
Reputation: 3,190

Post » Thu Oct 03, 2013 11:01 am

https://dl.dropboxusercontent.com/u/85412219/forumposts/spawning1only.capx
This also uses the sprite count, and sets the behavior "destroy outside layout"
B
240
S
62
G
33
Posts: 903
Reputation: 40,589

Post » Thu Oct 03, 2013 4:51 pm

thanks ill try these!
B
8
S
3
G
1
Posts: 87
Reputation: 1,493


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 16 guests