Closed OptimusPi closed 7 years ago
Currently TiledImageLayer does draw. It scrolls on by just like the tiles do. However, it's not implemented correctly. "Horizontal Offset" and "Vertical Offset" properties (set by Tiled Map Editor) are ignored.
This feels like something we should fix.
I will add the custom property for Tiled Map Editor called 'MGEBackground' which can be set to '1' to enable this feature. I will add a custom property in Tiled Map Editor called 'MGEParallax' which will set the parallax factor per layer.
These two things feel like they shouldn't be part of the core logic. If we go down this path where do we stop?
I think maybe we should focus on making the Tiled renderers open for extension and make it relatively easy to implement this stuff yourself.
The Camera2D
already provides paralax scrolling, so it's not really the responsibility of the Tiled renderer to do it also. Instead, it should be easy to connect these two bits of functionality together.
I'd be happy for the Tiled demo to show how to do it, but let's not overload the responsibilities of the core library.
This makes sense, thanks :) It was pretty easy to implement for me.
Okay so here's two valid questions:
Is the user supposed to make the background loop on their own horizontally? It's not really useful to have 1 chunk of background that scrolls on by and then nothingness is displayed once you walk past it.
What does a user do if they want a static background? One that stays in the same position no matter what? IT would be unfortunate if it always scrolled by even if the user wanted it t stay put.
Lastly, yes I want to implement this into a Demo at the very least so users can implement it in their own style.
You've basically answered your own questions.
Implement these features into a Demo so that other users can see how it works.
It's really up to you how to tackle it. Try to keep the logic contained in the demo but if you do feel you need to make changes to the library just make them and we'll discuss it in the PR.
So what is needed to be fixed here? Just the horizontal and vertical offset?
Just the horizontal and vertical offset?
Yep. I don't think we should worry about anything else.
@craftworkgames Vertical and horizontal offset are already applied as translation transform when rendering layers.
Currently TiledImageLayer does draw. It scrolls on by just like the tiles do. However, it's not implemented correctly. "Horizontal Offset" and "Vertical Offset" properties (set by Tiled Map Editor) are ignored.
Also there is a case where a user may want the background to be still, and always drawn the same regardless of the camera. I will add the custom property for Tiled Map Editor called 'MGEBackground' which can be set to '1' to enable this feature.
Also there should be a horizontal loop where the player cannot see the edge of any background image. Without having to adjust all of their backgrounds based on their map width. Especially if their background image is less than their screen size, etc.
Finally, parallax scrolling. I will add a custom property in Tiled Map Editor called 'MGEParallax' which will set the parallax factor per layer. (If this is not set, it will default to 0) The value can be from 0.0 - 1.0 (Demo.Camera is 0.25 * layerIndex)
Before checking in the final code, please make suggestions on what to exactly call 'MGEBackground' and 'MGEParallax' and we need to document this well. These string values will be converted to enum values in code after they are loaded.
tl;dr - Add Parallax scrolling backgrounds entirely designed by Tiled Map Editor.