How do I spawn a single sprite?

0 favourites
  • 7 posts
From the Asset Store
Pixel Sprites ala ReactorCore - Builder Hardware - Large pack of sprites!
  • 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?

  • 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...

  • 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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thank you for the responses. I am now trying variables and triggers.

  • "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.

  • 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.

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)