How do I spawn object and then delete said object?

0 favourites
  • 4 posts
From the Asset Store
Welcome! I-Spy (Hidden objects) is an educational puzzle that is more than just seek-and-find activities.
  • Hey fellow C3'ers!

    Trying to get the right coding for an object (stoplight) to spawn on a sprite if conditions are met (sprite.value = 0). When the value increases to 1 or higher, the object (stoplight) should disappear. If the value drops again to 0, back it comes. And so on.

    What's the best way to make this happen? I've tried so many combinations of conditions and actions but am making no ground. Any help/guidance is greatly appreciated.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Do you need to spawn it? You could just toggle the visibility.

    I'd use a container so that the lights are picked with the sprite and then set their visibility based on the picked sprites value.

  • Hey there! I appreciate your reply.

    I suppose I don't need to. This is more of my "testing sandbox" code to learn conditions/functions that I'm not ready to mix into my long-term project. I didn't understand the spawning function and was trying to learn how it worked.

  • Fair enough.

    Event 11 picks the "sprite" that was clicked on and if the cows variable = 0 on that tick then in your actions you try to spawn a red stoplight and add that as a child to the picked "sprite". You can't add a child when it hasn't been created yet, so swap those two actions around.

    In Event 12 you are trying to pick a different "sprite", based on UID however you have already picked a single sprite (the one you have clicked on). So unless those two sprites end up being the same you will never pick the one with the UID. That would mean that anything after that top level condition wouldn't run.

    Hard to suggest an alternative cause I can't see what you are trying to achieve in context. Upload your project file via dropbox etc. if you want any more help.

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