SOLVED Parallax Scrolling ... but with Instances

Moth27

Member
Is it possible to create a parallax scrolling effect with an Instance Layer?
It works fine with Background & Tile layers, but the Instance layers do not want to attach to my camera.

Any thoughts?
Thanks!
 

TheouAegis

Member
No, you have to loop through every I stance on the layer. It's a shame, I know. Maybe they will "fix" it in the future.
 
D

Deleted member 13992

Guest
No, you have to loop through every I stance on the layer. It's a shame, I know. Maybe they will "fix" it in the future.
No need for that. You can draw the visible/view contents of layers (objects, sprites, tiles, etc) to surfaces and redraw the surfaces scaled down and centered to the view for a parallax effect.

A drawback is that they will be scaled down, so not the same size as identical instances in the foreground. But I think it's better that way.

This is a bit more advanced than just using layer_x/y though, as you need to be comfortable with drawing everything manually, and understand rendering order.
 

Moth27

Member
No need for that. You can draw the visible/view contents of layers (objects, sprites, tiles, etc) to surfaces and redraw the surfaces scaled down and centered to the view for a parallax effect.

A drawback is that they will be scaled down, so not the same size as identical instances in the foreground. But I think it's better that way.

This is a bit more advanced than just using layer_x/y though, as you need to be comfortable with drawing everything manually, and understand rendering order.
Im gonna experiment with this! Thanks
 

Moth27

Member
Okay I tried the surface idea and it worked. I simply grabbed the camera x & y positions, divided those by 2 & in the Draw Event I drew the surface to those positions.

I decided to try this with a single object and it worked great as well. I now have parallax instances.

its simply 3 lines of code in the Draw Event:

var cam_x = camera_get_view_x(view_camera[0]) / 2;
var cam_y = camera_get_view_y(view_camera[0] / 2;

draw_sprite_ext( sprite_index , 1 , (cam_x + x) , (cam_y + y) , 1, 1, 0, c_white , 1);

Thanks so much for the help in solving this issue!
 
Top