Add value of all objects?

For questions about using Classic.

Post » Wed Aug 27, 2008 11:20 pm

Hi, how would I go about adding Value A of each instance of Object A?

i.e. I have 2 object a's, 1 with value a of 20 and the other of 10, how would I add this up to get 30?
Follow me on Twitter @evgLabs
B
33
S
14
G
4
Posts: 251
Reputation: 4,049

Post » Wed Aug 27, 2008 11:51 pm

No worries i made an example.
http://www.mediafire.com/?tet5nt7ptaj
It uses a loop with a condition "Pick highest Private Value" and then adds to global value, change private to 0 and then again until every private is 0.
B
4
S
2
G
4
Posts: 719
Reputation: 2,938

Post » Thu Aug 28, 2008 12:22 am

Or you could just use

+ For each Sprite
-> Add Sprite('Variable A') to global variable 'count'
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Thu Aug 28, 2008 12:46 am

Awesome! Thanks for the help.
Follow me on Twitter @evgLabs
B
33
S
14
G
4
Posts: 251
Reputation: 4,049

Post » Thu Aug 28, 2008 3:12 am

[quote="Ashley":8g5la992]Or you could just use

+ For each Sprite
-> Add Sprite('Variable A') to global variable 'count'[/quote:8g5la992]

Sorry, but if I do that it just keeps adding to the total, rather than just show the total. Unless, I did it wrong.
Follow me on Twitter @evgLabs
B
33
S
14
G
4
Posts: 251
Reputation: 4,049

Post » Thu Aug 28, 2008 1:28 pm

[quote="YetAnotherSuperhero":25lwcobb][quote="Ashley":25lwcobb]Or you could just use

+ For each Sprite
-> Add Sprite('Variable A') to global variable 'count'[/quote:25lwcobb]

Sorry, but if I do that it just keeps adding to the total, rather than just show the total. Unless, I did it wrong.[/quote:25lwcobb]
do you mean the event is running more than once? - either add trigger once or add always-> set count to 0 above it if you need it to always evaluate it
B
2
S
2
G
5
Posts: 236
Reputation: 2,122

Post » Fri Aug 29, 2008 5:28 pm

Yeah, I tried that but it's acting all funky. I'll post my cap in the upload so maybe someone can look at it.

It's up. (Custom Slider Bar not working)
Follow me on Twitter @evgLabs
B
33
S
14
G
4
Posts: 251
Reputation: 4,049


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests