How do I spawn a single sprite?

Get help using Construct 2

Post » Mon Jun 06, 2016 6:44 am

I am having trouble getting a single sprite to spawn when the event conditions are met.

When the player sprite is overlapping the block sprite I need a shadow sprite to spawn only once. If the player stays in position, only one shadow sprite is needed. If the player moves and comes back to overlapping the same sprite, I only want the original shadow sprite to exist unless it was previously destroyed.

What is happening is an infinite number of sprites are being created on top of one another.

How do I spawn just a single sprite?
B
42
S
20
G
6
Posts: 106
Reputation: 6,567

Post » Mon Jun 06, 2016 7:00 am

You could maybe use "on collision" which is a trigger (so it only happens once), instead of "is overlapping"

or you could maybe add "trigger once when true" to your overlap condition

or you might need to add a condition to check the count of the shadows, by choosing "compare two values" and checking shadow.count <1 (or whatever)

I'm not exactly sure what you're asking, but hopefully something here can help ya...
B
88
S
43
G
71
Posts: 601
Reputation: 43,669

Post » Mon Jun 06, 2016 7:31 am

I ran into the problem before. I still cant get it to function right. basically what he want is the game to make only one sprite when overlapping another sprite. And if im right he want to despawn the sprite when hes not overlapping it in theory it should work but contruct two engine just repeat it because of the condition it doesnt know it need to spawn one.

Id suggest that you do something like if overlapping spawn the sprite then change the condition in the action such as a variable to something else and when not overlapping change the variable back to the original variable

This way you can pretty much can control a overlapping condition and to prevent it from firing more then once. and once you step off you are just changing the variable so that when you overlap again all condition are met again.

Id done this so many time just for this effect. Id really wish there was a way to mark an event block to run once never again even if the condition was met again. (trigger once while true does not alway work) Cause id hate to use group just for a single event every time just for those event
B
52
S
24
G
6
Posts: 391
Reputation: 7,855

Post » Mon Jun 06, 2016 5:41 pm

Thank you for the responses. I am now trying variables and triggers.
B
42
S
20
G
6
Posts: 106
Reputation: 6,567

Post » Mon Jun 06, 2016 6:59 pm

"on collision with" worked perfectly. Thanks again.

But here's another question...
Is there a glossary of some type that shows you all the possible functions for events and actions, and where to find them? Sometimes just reading all the options inspires an idea. I didn't notice the "on collision with" or "trigger once while true" functions before because I was fishing for ideas inside and existing event that already had a trigger active, so it didn't show all the other possible trigger events.
There are also functions that are only found under actions or events. It seems like a glossary would be handy, or maybe even have the functions greyed out with a help window explaining why they are not available.
B
42
S
20
G
6
Posts: 106
Reputation: 6,567

Post » Tue Jun 07, 2016 4:13 am

Matthew de wrote:Is there a glossary of some type that shows you all the possible functions for events and actions, and where to find them?


https://www.scirra.com/manual/1/construct-2
In particular, check out the reference sections.
B
88
S
43
G
71
Posts: 601
Reputation: 43,669

Post » Wed Jun 08, 2016 6:38 am

System "compare two values" and checking shadow.count worked great. I only get the single shadow and not an infinity on the spawn.

Now, when a different object tries to spawn the same shadow sprite in a different location the <1 count prevents it from making the needed extra copy. Is there a way to allow multiple locations using the shadow.count technique? Can the counting be specific to an object instead of being a global count.

"trigger once while true" was too limiting.
B
42
S
20
G
6
Posts: 106
Reputation: 6,567


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 6 guests