Skip to content

feat: Add dynamic layer opacity support to flame_tiled#3843

Merged
ufrshubham merged 2 commits intomainfrom
devkage/tiled-layer-dynamic-opacity
Mar 5, 2026
Merged

feat: Add dynamic layer opacity support to flame_tiled#3843
ufrshubham merged 2 commits intomainfrom
devkage/tiled-layer-dynamic-opacity

Conversation

@ufrshubham
Copy link
Member

Description

flame_tiled supported reading layer opacity from .tmx files at load time, but there was no way to change a layer's opacity at runtime. This PR adds setLayerOpacity and getLayerOpacity methods to RenderableTiledMap, enabling users to dynamically adjust layer opacity after the map has loaded.

  • RenderableLayer.opacity is converted from a late field (computed once at init) to a getter/setter pair. The getter returns the effective opacity (own × parent chain); the setter stores the own opacity and fires onOpacityChanged().
  • A protected onOpacityChanged() hook is added to RenderableLayer. FlameTileLayer overrides it to rebuild its cached Paint object; GroupLayer overrides it to propagate the call recursively to all children so nested tile layers stay in sync.
  • RenderableTiledMap gains setLayerOpacity(int layerIndex, {required double opacity}) and getLayerOpacity(int layerIndex).
  • FlameImageLayer required no changes — it already reads opacity live on every render() call.

Checklist

  • I have followed the Contributor Guide when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • [NA] I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

Related Issues

Closes #3066

@ufrshubham ufrshubham self-assigned this Mar 5, 2026
@ufrshubham ufrshubham requested a review from a team March 5, 2026 14:09
Copy link
Member

@spydon spydon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm!

@ufrshubham ufrshubham merged commit b170299 into main Mar 5, 2026
10 checks passed
@ufrshubham ufrshubham deleted the devkage/tiled-layer-dynamic-opacity branch March 5, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support dynamic changes to the layer opacity on tiled maps

2 participants