Hundreds of features to explore
Games made in Construct
Your questions answered
Popular & trusted by schools and Universities world-wide
Construct 3 runs in the browser & works offline
Students do not need accounts with us
World class complete documentation
Official and community submitted guides
Learn and share with other game developers
Upload and play games from the Construct community
Game development stories & opinions
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
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
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).
Just realized it was instances of the same sprite so you can make a loop like this:
It doens't have to be "for each (ordered)" you can use the regular "for each" loop instead.
Develop games in your browser. Powerful, performant & highly capable.
Thanks Mpplant & Frozen Dev!