Events for objects that is pinned to object

0 favourites
  • 6 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • I understand that this will sound confusing but here's the best way I can explain this.

    I currently have a Fireworks style game. Each firework has a particle effect (sparks) pinned to it. When the firework flies up, the particle sprays, when it goes down, the particle stops spraying.

    This works perfectly well for one firework at a time, however when more than one firework is in action, all particle effects won't spray if at least one of the fireworks is going down.

    I've been working on this for about an hour, my best guess is that because of the way I've written it, the events are acting on all instances, instead of the instance pinned to that object. I figured that I could have a condition for "If sparks is pinned to firework", but the condition doesn't exist. The only condition that Pin Behaviour has is "Is Pinned" which doesn't help me at all.

    I've also tried conditions to check if the spark's position is equal to the firework's position, and if the firework overlaps the sparks, but neither work.

    Here's a screenshot of my fireworks event sheet:

    <img src="https://dl.dropbox.com/u/30381754/FireworkSheet.png" border="0" />

    Any help will be greatful, feel free to ask about the event sheet!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yeah I see the issue.

    You are setting the particle to not spray but you aren't picking out one, so it'll do them all.

    You need a nested foreach under the foreach firework. And you use "PinnedUID" on the particle to compare to parent UID.

    Pseudo code:

    For each firework

    Firework moving down? Set Flipped

                          Set Mirrored

                          Move to Layer 2

    For each particle

       Particle.PinnedUID = Firework.UID? Set not spraying

    Also one minor tip, you can spawn particle from firework.. simply saves having to specify an x and y position using system to spawn it.

  • Using containers would simplify your code a lot. No need to create sparks or pick them separately as they would be automatically created/picked/destroyed with the firework sprite.

  • Here is an quick example I made:

    Fireworks example

  • Wow, both methods work! I didn't notice there was a variable that contains the UID for the pinned object! Thank you both very much!! :D

  • thanks for the heads up on the containers works really well. I was having a similar issue

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