Parallax Question

nlolotte

Member
Hello,

How do I keep a layer with in view on the Y axis but also accommodate for parallax scrolling?

I have the following code:

Code:
if obj_player.y > view_h-48
{
layer_y(Houses_Close,camera_get_view_y(view_camera[0])+128);
layer_y(Houses_Far,camera_get_view_y(view_camera[0])+64);
layer_y(Mountains,camera_get_view_y(view_camera[0])+16);
}
I tried:

Code:
if obj_player.y > view_h-48
{
layer_y(Houses_Close,camera_get_view_y(view_camera[0])/2+"value");
layer_y(Houses_Far,camera_get_view_y(view_camera[0])/2+"value");
layer_y(Mountains,camera_get_view_y(view_camera[0])/2+"value");
}
This does allow for the effect but the layers aren't always in view. My room height is 1024. Any help would be appreciated.

Thanks,

Nathaniel
 

zATARA_0

Member
you could use 'clamp' to make sure they stay within the range you want.

clamp(view_camera[0])/2+"value", 0, room_height);
 

nlolotte

Member
you could use 'clamp' to make sure they stay within the range you want.

clamp(view_camera[0])/2+"value", 0, room_height);
Thanks for your reply,

I tried this just now but it doesn't seem to give me the desired results. The layer still leaves the view window.
 
Last edited:
Top