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

[SOLVED] Does layer_vspeed effect instances?

Pfap

Member
I have a lava layer that I was hoping to manipulate with layer functions.

Create event:
Code:
cleared = false;
lava = layer_get_id("lava_layer");
show_debug_message(lava);
show_debug_message(layer_get_y(lava));
alarm[0] = 60;
Alarm[0] event:
Code:
show_debug_message("lava");
cleared = true;

//start the layer moving up the screen
layer_vspeed(lava,5);
The layer starts to move, but the instances on that layer do not.
Step event:
Code:
if layer_get_vspeed(lava) > 0{
 show_debug_message("the layer is moving");
}
Is this behavior expected?


Edit:
I just used with(objects_on_layer){}, but why would you want to move a layer, if it doesn't effect the instances on it?
 
Last edited:
B

Bayesian

Guest
I just used with(objects_on_layer){},
Where did you find objects_on_layer? it doesn't work for me.
why would you want to move a layer, if it doesn't effect the instances on it?
To move sprite/asset and background layers.

If you open the room editor you'll see that only sprite/asset and BG layers have speed boxes you can edit.
 

Pfap

Member
Where did you find objects_on_layer? it doesn't work for me.

To move sprite/asset and background layers.

If you open the room editor you'll see that only sprite/asset and BG layers have speed boxes you can edit.
I have 2 object types on the layer, so I was just using with(objects_on_layer) as a lazy shorthand. But, I thought instances on the layer would move with it. It's not a big deal and I do remember it working with tiles, I was just expecting it to work with instances too.
 

Roalinn

Member
İ understood you want to move layer and the objects in that layer that's right ?

maybe you can do :

in object's create event:
Code:
lava = layer_get_id("lava_layer");
layers_vspeed = layer_get_vspeed(lava);
(Note : if you want you can put this code in step event too so if you will change layer's speed, automaticly change object's speed too)

then object's step event:
Code:
y += layers_vspeed
so your object's move with layer's speed
 
Last edited:

Pfap

Member
İ understood you want to move layer and the objects in that layer that's right ?

maybe you can do :

in object's create event:
Code:
lava = layer_get_id("lava_layer");
layers_vspeed = layer_get_vspeed(lava);
(Note : if you want you can put this code in step event too so if you will change layer's speed, automaticly change object's speed too)

then object's step event:
Code:
y += layers_vspeed
so your object's move with layer's speed
Yea, that's a good idea.
 
Top