• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Turning Multiple Objects *SOLVED*

Odolwa

Member
I have an object with separate hitbox objects matching its movement. I want to make a shorthand for the code when manipulating the 'image_angle' of all of these at once. At present I have it as follows:
Code:
image_angle += 1 //The main object
obj_a.image_angle += 1 //The hitbox objects a, b & c
obj_b.image_angle += 1
obj_c.image_angle += 1
If I wanted to reduce all of that to a single line variable do I use an array? I've tried writing the following, but I get an error so I must be doing it wrong:
Code:
var array[3] = obj_a.id, obj_b.id, obj_c.id
Can anyone help? Thanks.
 

Paskaler

Member
You should use this code to initialize the array

Code:
var array;
array[0] = obj_a;
array[1] = obj_b;
// ... and so on
 

Odolwa

Member
Ok, so I created the array as you described and then tried manipulating the 'image_angle' as follows:
Code:
array.image_angle = image_angle //Image angles of all hitbox objects in the array will match the image angle of the main object they are attached to
However, an error is thrown which says this is an illegal use of arrays. How should I write the code then, to get the desired effect?
 
Top