-
-
Notifications
You must be signed in to change notification settings - Fork 984
feat: [flame_tiled] Components added to Layers draw in order. Parallax is now WYSIWYG. #3653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: [flame_tiled] Components added to Layers draw in order. Parallax is now WYSIWYG. #3653
Conversation
…derable layer by name. Expanded the size of the example map and fixed the move effect to better highlight this module's features.
…ayers even if �isible is false. While, invisible layers will not draw, they will load as expected.
…aptured. All other 'failing' reports are < 1% error difference!
feat:
[flame_tiled] Layers respect draw-order of added Componentsfeat
[flame_tiled] Layers respect draw-order of added Components
feat
[flame_tiled] Layers respect draw-order of added Components
@TheMaverickProgrammer This PR needs a little conflict resolving with main, but it should be quite trivial, it's mostly formatting. |
Will do, and I'll be done with this soon. |
…fted.tmx. Also, added an override for field 'paint' at the RenderLayer class so that any layer can have their paint easily modified.
@spydon There's only two tests failing by a margin: the orthographic map with parallax effect and the shifted isometric map test. The ortho map has a questionable golden test. If I open up the map in Tiled and center the viewport on The shifted isomorphic map has me reviewing the code many times over. I'm unsure what I missed. It's just the group is shifting too much. So some extra offset is happening somewhere. What's odd is that all other tests pass without issue. Maybe if you do a quick review you'll catch it before I do. I'll try to be done with this tomorrow. |
Can you see what is wrong in the test? Golden tests on Flutter differ slightly on different OS:es, but I guess the diff is bigger than just a pixel off? I'll see if I have time to review it today, and I'll add some other reviewers that are more familiar with this code. |
@kurtome @ufrshubham @jtmcdole could you maybe review this PR if you have time? Since you are much more familiar with the flame_tiled code than I am. 😇 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remember correctly the original implementation combined the layers into a single image, which was a performance optimization. So, I assume this CL gets rid of that optimization?
Personally I'm fine with that, I always try to keep my Tiled maps small to avoid performance issues.
The code changes look reasonable to me on a quick review. I could try to test this on my game later this week if that's helpful.
packages/flame_tiled/lib/src/renderable_layers/tile_layers/unsupported_layer.dart
Show resolved
Hide resolved
Yes for the |
I found and patched the issue for the So it's a bit of a mess but solvable now that I see the mistake. My next push ought to be the final. EDIT: The math revealed we can translate the canvas for each layer with local parallax values as long as our local parallax values takes into account their parent's as well. Writing up a fix. |
…g partial parallax locality. This is equivalent to the product of all parent parallax coefficients.
I don't think that's correct; TiledAtlas was added to batch rendering, but I'm pretty sure that was done on a per-layer. I'm not sure if I was clipping the batch draw to the camera (which would have been a good idea), and I wanted to add some y-order optimizations so external components could be rendered between the layers. It sounds like this PR is aiming to fix the later.
Its a bit large of a PR for me to review while sipping my morning coffee, for sure. I don't see any tests showing "Foreground tiles obscure sprites." - or I am I missing some golden images? |
Good point. I can add a test for this feature. Do I also have permission to update the orthogonal golden? |
Go for it. :) |
Moving this back into |
…olve canvas recorder fringe case failing to capture the offset scene due to camera transforms.
Description
Primarily, this PR allows a creator to add components to a Tiled Component's
RenderableLayer
. Since these layers now draw their child component's after they draw their tile map data to the canvas, the outcome is that paintable components (such asSpriteComponent
) are drawn in the order of the layers which enables foregrounds and other detail layers to visually behave as expected.Second, the parallax effect and infinite tiling of layers is optimized. Each layer only incurs at most one canvas translate.
Last but not least, the map renders 1:1 with Tiled even with parallax effects. Flame is now WYSIWYG!
✏️ Note that this is not a breaking change!
PR Demonstration
Video of the
flame_tiled
example application with changes.https://github.com/user-attachments/assets/bfa09575-be7b-4ae3-99af-96336ad44f67
Video of components drawing as expected in a custom Flame game.
https://github.com/user-attachments/assets/7a1b3bc7-7365-4a2d-81cc-7f23b6e12fc4
Here's an example of adding the player to a layer beneath the "foreground" layer.

Note that the water layer is also on top of the foreground layer and both layers are on top of the player as expected.
Checklist
docs
and added dartdoc comments with///
.examples
ordocs
.Breaking Change?
Related Issues
Closes #3594