• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!

Legacy GM Cant change alpha of multiple object - did I use 'with' wrong?

jobjorgos

Member
I want to do image_alpha -=0.05 to multiple objects at the same time, and somehow this is not working.
IT works if I just do image_alpha -= 0.05 and then apply to the specify object in the code form windowborder, but when I do it on the way below with script it does not affect those objects somehow. Did I use 'with' on the wrong way?
Code:
with (obj_boots0) and (obj_boots1) and (obj_boots2) and (obj_boots3)
{
      image_alpha -= 0.05;
}
 
Last edited:

Simon Gust

Member
Multiple objects don't work in a with statement, you'll most likely end up changing the alpha of the second object in your resource tree if you follow the logic of your code.
You should either do them individually or better, create a parent object for these 4 and call the parent object.
 

jo-thijs

Member
I want to do image_alpha -=0.05 to multiple objects at the same time, and somehow this is not working.
IT works if I just do image_alpha -= 0.05 and then apply to the specify object in the code form windowborder, but when I do it on the way below with script it does not affect those objects somehow. Did I use 'with' on the wrong way?
Code:
with (obj_boots0) and (obj_boots1) and (obj_boots2) and (obj_boots3)
{
      image_alpha -= 0.05;
}
So many people try this, even though there is no reason at all to think this would work.
Some reference material:
https://forum.yoyogames.com/index.php?threads/how-not-to-use-and.12871/
https://forum.yoyogames.com/index.php?threads/one-variable-to-multiple-objects.25657
https://forum.yoyogames.com/index.php?threads/solved-switch-statement-help.6799
(I know there are even better references, but I couldn't find them in a timely manner).
 

jobjorgos

Member
Multiple objects don't work in a with statement, you'll most likely end up changing the alpha of the second object in your resource tree if you follow the logic of your code.
You should either do them individually or better, create a parent object for these 4 and call the parent object.
Oh oke I didnot know 'with' does not work with multiple objects at same time... good to know that I use it wrong!
Then I will do the individual or parent method! Thanks for the solution!!
 
Top