Thanks, @Dragosha ! You have achieved what I thought was impossible, amazing! The sprite scrolling now works for sprites with arbitrary sizes and with multiple sprites in the same atlas.
I took your project played around with it and now the sprite scrolling works great in any direction.
I added some runtime controls:
- to change the sprite from a random cat image to a seamless pattern image (checkerboard).
- to increase/decrease the scroll speed.
- to activate/deactivate independent x and y scrolling.
- reset the sprite’s position.
I think this could be a great starting project for someone looking to implement advanced sprite scrolling,.
There is one remaining BIG ISSUE (that I know of) - when the sprite wraps (at the seams) there is a little bit of flicker. If this could be solved then the sprite scrolling mechanic would be bulletproof.
In the future, if Defold would get the ability to scroll sprites with shaders in a much simpler way (closer to Godot’s approach) that would be preferable, since in this test project there is a LOT of code just to achieve basic sprite scrolling functionality.
Defold Sprite Scroll Example.zip (1.6 MB)