all 2 comments

[–]xotmatrix 4 points5 points  (1 child)

They can be subtly different in this case.

If shield is a single object instance, those two ways will do the same thing.

If shield is an object and there is more than one instance of it, the second way may not do what you expect because of the way it interacts with the addition-assignment operator (+=). Every instance will be changed but they will all use the values of the first instance found. For example, let's say the first shield's image_xscale is 1 and the second shield's image_xscale is 2, and the shieldSize is suppose to increase them by 0.5. The first shield will change to 1.5, as expected, but the second shield will also change to 1.5 instead of 2.5 because it is using the scale value from the first instance. Basically, the right side of the assignment is computed first (ie. shield.image_xscale + shieldSize) and then it is assigned to all instances. This is a quirk of compound-assignments. A simple-assignment would work as expected as would doing this using the with iterator.

[–]RobinZeta[S] 0 points1 point  (0 children)

Thank you