0

使用 flame_tiled 插件加载平铺地图。通过 TiledComponent 加载地图,如下所示:

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

这在移动设备上运行良好。但是,当使用 Flutter for Web 时出现以下错误:

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

    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

如果没有添加 'tiledcomponent' 并且只渲染了一些 Sprite,这些 Sprite 也适用于 Flutter Web,但不适用于 TiledComponent。有什么解决办法吗?还是解决方法?

Flutter Channel 测试版,1.23.0-18.1.pre flame 0.28.0 flame_tiled 0.1.0。平铺 0.6.0

4

1 回答 1

2

不幸的是,该软件包不支持 web,它使用 Flames SpriteBatchAPI,它使用 Flutterscanvas.drawAtlas方法,该方法尚未在 web 上实现。

根据您要构建的内容,您可以尝试Bonfire,它有自己的引擎来渲染平铺地图,并且它支持 web

于 2020-11-12T12:10:52.957 回答