litiengine icon indicating copy to clipboard operation
litiengine copied to clipboard

Implement parallax scrolling

Open nightm4re94 opened this issue 5 years ago • 6 comments

Most awesome 2D games have a parallax scrolling engine. We should support this too. Maybe the map creator would simply set some sort of "scrollSpeed" Layer property (default: 1.0) and then all layers would be scrolled by our wizardry.

nightm4re94 avatar Mar 19 '19 10:03 nightm4re94

It's currently open as a feature request on the Tiled forums. We should determine whether it's worth waiting for support from Tiled, or alternatively, reach out and see if we can figure out how it will eventually be implemented in Tiled.

Parallax scrolling for tile layers could be problematic, as it would need to be taken into account when resolving tiles, and the tiles would still be the same size as the other layers.

TheRamenChef avatar Mar 19 '19 15:03 TheRamenChef

@TheRamenChef That's a nice finding. Seeing the creation date of that issue though, I don't have much hope that this will get implemented any time soon. But I totally agree on reaching out to bjorn and see what he has planned regarding this topic.

steffen-wilke avatar Mar 19 '19 19:03 steffen-wilke

I can't imagine this feature being implemented in Tiled too soon either.

Regarding the calculation of tile boundaries on scrolling layers, I had in mind that the Tile grid would still persist as is, only considering the unscrolled tile layer (-> the default foreground plane). The offset of scrolled layers would be a solely visual effect, not influencing any Tile calculations. The following image taken from Stackoverflow shows quite well what I had intended: Parallax sample image Tile sizes would be the same for all layers, but the scrolling layers would need to "be bigger"(cover more tiles) than the layers with default scrolling. The default layers would only cover a smaller portion of the map, depending on how big the viewport is.

There are plenty of resources on implementing a parallax scrolling effect.

nightm4re94 avatar Mar 20 '19 10:03 nightm4re94

Any updates on this? Have we contacted bjorn yet?

TheRamenChef avatar Apr 17 '19 01:04 TheRamenChef

No, not yet. And no other updates currently.

steffen-wilke avatar Apr 17 '19 20:04 steffen-wilke

This is, in fact, already a feature in Tiled: https://doc.mapeditor.org/en/stable/manual/layers/#parallax-factor

We are still only supporting Tiled v1.2 maps - should update our map specifications urgently to the more recent versions of the tmx format.

Closing this issue in favor of #464.

nightm4re94 avatar Jul 20 '22 16:07 nightm4re94