Counting Particles

Get help using Construct 2

Post » Tue Jan 28, 2014 7:50 am

From the manual:

"Note that due to the way Construct 2 expressions work, if you have multiple Particle object instances, this will only return the particle count for one of the instances - use a For Each loop to count multiple instance's total particle count."

How?

I have put my particle generators into a family so that I can use a For Each loop, and I have a text box that is set to count the total number of particles, but it's only showing me one instance. I've also tried using 'add' instead of 'set', and I just get an ever increasing number.

I know this should be pretty simple, but I just can't seem to get my head around it.AnD4D2014-01-28 07:51:09
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
79
S
12
G
7
Posts: 963
Reputation: 10,721

Post » Tue Jan 28, 2014 8:06 am

Would this work?

system every tick set global variable ParticleCount to 0

system for each particle object
trigger once
- add object.particlecount to global variable ParticleCount

system every tick set text: ParticleCount
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Jan 28, 2014 8:10 am

Would something like this do the trick ?

I didn't put any evaluation every tick, just made a function to count with a local variable. P1 and P2 (particle spawners) have different rates, I display the respective count, and the total.Guizmus2014-01-28 08:11:23
B
17
S
8
G
4
Posts: 461
Reputation: 6,157

Post » Tue Jan 28, 2014 8:51 am

Interesting... it seems you have to use the add command, as well as using a static local variable.

Thanks everybody!
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
79
S
12
G
7
Posts: 963
Reputation: 10,721


Return to How do I....?

Who is online

Users browsing this forum: Lancifer, Yahoo [Bot] and 60 guests