Events for objects that is pinned to object

Get help using Construct 2

Post » Sun Mar 17, 2013 3:00 am

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:


Any help will be greatful, feel free to ask about the event sheet!
B
24
S
5
G
1
Posts: 89
Reputation: 3,015

Post » Sun Mar 17, 2013 8:47 am

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.
silkc22013-03-17 08:50:03
B
20
S
6
G
2
Posts: 157
Reputation: 3,109

Post » Sun Mar 17, 2013 9:21 am

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.
B
24
S
8
G
7
Posts: 756
Reputation: 7,202

Post » Sun Mar 17, 2013 11:23 am

Here is an quick example I made:

Fireworks example
B
24
S
8
G
7
Posts: 756
Reputation: 7,202

Post » Sun Mar 17, 2013 1:56 pm

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
B
24
S
5
G
1
Posts: 89
Reputation: 3,015

Post » Thu Mar 19, 2015 12:00 am

thanks for the heads up on the containers works really well. I was having a similar issue
B
7
S
1
Posts: 7
Reputation: 396


Return to How do I....?

Who is online

Users browsing this forum: kamens503 and 19 guests