How do I calculate all of the instance variables?

Get help using Construct 2

Post » Fri Feb 03, 2017 10:21 am

How can I calculate all of the instance variables added up if there are X instances with different variables?
Sprite 1 (1) .Weight = 10
Sprite 1 (2) .Weight = 5
Sprite 1 (3) . Weight = 2
TotalWeight = 17
yes.
__
|:D|
Gamjolt account:http://gamejolt.com/profile/masgame/409321/
B
37
S
15
G
3
Posts: 40
Reputation: 5,002

Post » Fri Feb 03, 2017 10:31 am

You can for example make a variable named "Total Weight" and set it to: sprite1.weight+sprite2.weight+sprite3.weight

The "total weight" variable will then store the total values of the sprites instance values added up
B
63
S
26
G
16
Posts: 816
Reputation: 14,573

Post » Fri Feb 03, 2017 10:33 am

Global Var. Sum = 0

| Set Sum to (Sprite1(0).WeightSprite + Sprite1(1).WeightSprite + Sprite1(2).WeightSprite )
or use a loop index.

Remember the first instance of a Sprite would always be Sprite1(0).
"The intent is to provide subscribers with a sense of pride and accomplishment for unlocking different features...."
B
42
S
18
G
32
Posts: 818
Reputation: 20,779

Post » Fri Feb 03, 2017 10:38 am

Just realized it was instances of the same sprite so you can make a loop like this:

Image

It doens't have to be "for each (ordered)" you can use the regular "for each" loop instead.
B
63
S
26
G
16
Posts: 816
Reputation: 14,573

Post » Sat Feb 04, 2017 2:53 am

Thanks Mpplant & Frozen Dev!
yes.
__
|:D|
Gamjolt account:http://gamejolt.com/profile/masgame/409321/
B
37
S
15
G
3
Posts: 40
Reputation: 5,002


Return to How do I....?

Who is online

Users browsing this forum: SERGIOManOwaR and 5 guests