• 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!

How to move all objects together with their layer

J

Jaydabblju

Guest
I am new to GM2 and tried to move a whole layer. But the instances of this layer stay on their position.

I tried:
Code:
// creating buttons
instance_create_layer(0,0,"menu",obj_btn_new_game);
instance_create_layer(0,100,"menu",obj_btn_load_game);

// moving the whole layer down
layer_y("menu",200);
But the objects don't move.

My target is to create a menu on a layer. After clicking on a button of that menu the whole layer shall move out of the screen.
 
J

Jaydabblju

Guest
So moving the layer doesn't affect the postition of its instances? I have to go through all instances manually?

For what can I use "layer_y" and "layer"x" if the instances don't move?
 

Yal

🐧 *penguin noises*
GMC Elder
The with loop FrostyCat posted will move all object instances, while technically being "manually going through all instances" it's just 6 lines of code to do it (because we tell it to loop over all objects instead of just specific objects or a specific ID).
 
J

Jaydabblju

Guest
Yes I get that.
But again: For what can I move the layer with "layer_x" and "layer_y" if the instances on this layer stay on their positions?
 

BiTrunade

Member
But again: For what can I move the layer with "layer_x" and "layer_y" if the instances on this layer stay on their positions?
I highly agree. It would have made a very useful feature to move all instances inside the layer without having to loop through all of them, not that I am against using with, it just would have made the process more straightforward.
 

Yal

🐧 *penguin noises*
GMC Elder
I highly agree. It would have made a very useful feature to move all instances inside the layer without having to loop through all of them, not that I am against using with, it just would have made the process more straightforward.
Loops pretty much is how you do batch operations... 🦈
 
Top