diff --git a/doc/examples/tiled/lib/main.dart b/doc/examples/tiled/lib/main.dart index 445ab3991..87c0f1658 100644 --- a/doc/examples/tiled/lib/main.dart +++ b/doc/examples/tiled/lib/main.dart @@ -21,17 +21,21 @@ class TiledGame extends BaseGame { } void _addCoinsInMap(TiledComponent tiledMap) async { - final ObjectGroup obj = + final ObjectGroup objGroup = await tiledMap.getObjectGroupFromLayer("AnimatedCoins"); - if (obj == null) { + if (objGroup == null) { return; } - for (TmxObject obj in obj.tmxObjects) { + objGroup.tmxObjects.forEach((TmxObject obj) { final comp = AnimationComponent( - 20.0, 20.0, Animation.sequenced('coins.png', 8, textureWidth: 20)); + 20.0, + 20.0, + Animation.sequenced('coins.png', 8, + textureWidth: 20, textureHeight: 20), + ); comp.x = obj.x.toDouble(); comp.y = obj.y.toDouble(); add(comp); - } + }); } }