Search code examples
flutterflutter-webtiledflame

flame_tiled and/or tiled package gives error when running on web


Using flame_tiled plugin to load a tiled map. Loading a map through the TiledComponent like so:

tiledComponent = TiledComponent("new4.tmx", Size(32.0,32.0));
add(tiledComponent);

This works well on a mobile.However, when using flutter for web getting the following error:

══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
The following UnimplementedError was thrown during paint():
UnimplementedError

and

    The following RenderObject was being processed when the exception was fired: GameRenderBox#0eebf:
  parentData: <none> (can use size)
  constraints: BoxConstraints(w=929.0, h=932.0)
  size: Size(929.0, 932.0)
This RenderObject has no descendants.
════════════════════════════════════════════════════════════════════════════════════════════════════
Another exception was thrown: UnimplementedError

If the 'tiledcomponent' is not added and only some Sprite is rendered that too works on flutter web but not the TiledComponent. Any solution? Or a workaround?

Flutter Channel beta, 1.23.0-18.1.pre flame 0.28.0 flame_tiled 0.1.0. tiled 0.6.0


Solution

  • Unfortunately the package don't support web, it uses Flames SpriteBatch API, which uses Flutters canvas.drawAtlas method and that method isn't implemented on web yet.

    Depending on what you want to build, you could try Bonfire, it has its own engine to render a tiled map, and it supports web