From 147775518b429d71c195d09a9cd8c0e51072a88a Mon Sep 17 00:00:00 2001 From: Erick Zanardo Date: Tue, 11 Aug 2020 22:05:14 -0300 Subject: [PATCH 1/9] Updating changelog for the next development iteration --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33903e71fa9..0060546f94a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # CHANGELOG +## [next] + ## 0.25.0 - Externalizing Tiled support to its own package `flame_tiled` - Preventing some crashs that could happen on web when some methods were called From 8fbd7880190320225575db58bdd34cc4c72aaef5 Mon Sep 17 00:00:00 2001 From: Erick Zanardo Date: Sat, 22 Aug 2020 12:59:38 -0300 Subject: [PATCH 2/9] Improving Flame image autocaching --- lib/images.dart | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/images.dart b/lib/images.dart index 8c7f2a4bd68..aecb86aa534 100644 --- a/lib/images.dart +++ b/lib/images.dart @@ -6,7 +6,7 @@ import 'dart:convert' show base64; import 'package:flame/flame.dart'; class Images { - Map loadedFiles = {}; + Map loadedFiles = {}; void clear(String fileName) { loadedFiles.remove(fileName); @@ -22,16 +22,16 @@ class Images { Future load(String fileName) async { if (!loadedFiles.containsKey(fileName)) { - loadedFiles[fileName] = await _fetchToMemory(fileName); + loadedFiles[fileName] = _ImageAssetLoader(_fetchToMemory(fileName)); } - return loadedFiles[fileName]; + return await loadedFiles[fileName].retreive(); } Future fromBase64(String fileName, String base64) async { if (!loadedFiles.containsKey(fileName)) { - loadedFiles[fileName] = await _fetchFromBase64(base64); + loadedFiles[fileName] = _ImageAssetLoader(_fetchFromBase64(base64)); } - return loadedFiles[fileName]; + return await loadedFiles[fileName].retreive(); } Future _fetchFromBase64(String base64Data) async { @@ -52,3 +52,16 @@ class Images { return completer.future; } } + +class _ImageAssetLoader { + _ImageAssetLoader(this.future); + + Image loadedImage; + Future future; + + Future retreive() async { + loadedImage ??= await future; + + return loadedImage; + } +} From 096807bdcc60b114dae7cf842c4b0179e3c68546 Mon Sep 17 00:00:00 2001 From: Erick Zanardo Date: Sat, 22 Aug 2020 13:12:22 -0300 Subject: [PATCH 3/9] Fixing particles example and updating changelog --- CHANGELOG.md | 1 + doc/examples/particles/lib/main.dart | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0060546f94a..503c8b47700 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # CHANGELOG ## [next] +- Improving Flame image auto cache ## 0.25.0 - Externalizing Tiled support to its own package `flame_tiled` diff --git a/doc/examples/particles/lib/main.dart b/doc/examples/particles/lib/main.dart index 150c438f274..d05c39bd3e8 100644 --- a/doc/examples/particles/lib/main.dart +++ b/doc/examples/particles/lib/main.dart @@ -292,7 +292,7 @@ class MyGame extends BaseGame { Particle imageParticle() { return ImageParticle( size: const Size.square(24), - image: Flame.images.loadedFiles['zap.png'], + image: Flame.images.loadedFiles['zap.png'].loadedImage, ); } @@ -522,7 +522,7 @@ class MyGame extends BaseGame { const rows = 8; const frames = columns * rows; const imagePath = 'boom3.png'; - final spriteImage = Flame.images.loadedFiles[imagePath]; + final spriteImage = Flame.images.loadedFiles[imagePath].loadedImage; final spritesheet = SpriteSheet( rows: rows, columns: columns, From a022d7fec1e5b015adc24244200f1b8b3f5e2e5c Mon Sep 17 00:00:00 2001 From: DinoAndCat Date: Mon, 24 Aug 2020 01:12:12 +0800 Subject: [PATCH 4/9] fix bug in the Box2DGame's add and addLater method , when the Component extends BodyComponent and mixin HasGameRef or other mixins ,the mixins will not be set correctly --- lib/box2d/box2d_game.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/box2d/box2d_game.dart b/lib/box2d/box2d_game.dart index 501a5136236..b28d00cb4fa 100644 --- a/lib/box2d/box2d_game.dart +++ b/lib/box2d/box2d_game.dart @@ -16,6 +16,7 @@ class Box2DGame extends BaseGame { @override void add(Component c) { if (c is BodyComponent) { + preAdd(c); box.add(c); } else { super.add(c); @@ -25,6 +26,7 @@ class Box2DGame extends BaseGame { @override void addLater(Component c) { if (c is BodyComponent) { + preAdd(c); _addLater.add(c); } else { super.addLater(c); From a27904a212b8f33fe88738793af84c2ff7cd87b7 Mon Sep 17 00:00:00 2001 From: DinoAndCat Date: Mon, 24 Aug 2020 16:17:54 +0800 Subject: [PATCH 5/9] fix bug in the Box2DGame's add and addLater method , when the Component extends BodyComponent and mixin HasGameRef or other mixins ,the mixins will not be set correctly --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0060546f94a..e45a75b8c35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # CHANGELOG ## [next] +- fix bug in the Box2DGame's add and addLater method , when the Component extends BodyComponent and mixin HasGameRef or other mixins ,the mixins will not be set correctly ## 0.25.0 - Externalizing Tiled support to its own package `flame_tiled` From fe264ce9ea81ab0fffdd031e105d44d623e150ba Mon Sep 17 00:00:00 2001 From: DinoAndCat Date: Mon, 24 Aug 2020 16:18:20 +0800 Subject: [PATCH 6/9] fix bug in the Box2DGame's add and addLater method , when the Component extends BodyComponent and mixin HasGameRef or other mixins ,the mixins will not be set correctly --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e45a75b8c35..803d8a21a9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # CHANGELOG ## [next] -- fix bug in the Box2DGame's add and addLater method , when the Component extends BodyComponent and mixin HasGameRef or other mixins ,the mixins will not be set correctly + - fix bug in the Box2DGame's add and addLater method , when the Component extends BodyComponent and mixin HasGameRef or other mixins ,the mixins will not be set correctly ## 0.25.0 - Externalizing Tiled support to its own package `flame_tiled` From d74758faf4c800d3922532be92d67ecabc9fe1b2 Mon Sep 17 00:00:00 2001 From: Erick Zanardo Date: Sat, 29 Aug 2020 11:44:36 -0300 Subject: [PATCH 7/9] PR suggestions --- lib/images.dart | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/images.dart b/lib/images.dart index aecb86aa534..75903d5e81e 100644 --- a/lib/images.dart +++ b/lib/images.dart @@ -6,7 +6,7 @@ import 'dart:convert' show base64; import 'package:flame/flame.dart'; class Images { - Map loadedFiles = {}; + Map loadedFiles = {}; void clear(String fileName) { loadedFiles.remove(fileName); @@ -22,14 +22,14 @@ class Images { Future load(String fileName) async { if (!loadedFiles.containsKey(fileName)) { - loadedFiles[fileName] = _ImageAssetLoader(_fetchToMemory(fileName)); + loadedFiles[fileName] = ImageAssetLoader(_fetchToMemory(fileName)); } return await loadedFiles[fileName].retreive(); } Future fromBase64(String fileName, String base64) async { if (!loadedFiles.containsKey(fileName)) { - loadedFiles[fileName] = _ImageAssetLoader(_fetchFromBase64(base64)); + loadedFiles[fileName] = ImageAssetLoader(_fetchFromBase64(base64)); } return await loadedFiles[fileName].retreive(); } @@ -53,8 +53,8 @@ class Images { } } -class _ImageAssetLoader { - _ImageAssetLoader(this.future); +class ImageAssetLoader { + ImageAssetLoader(this.future); Image loadedImage; Future future; From e37a0856ed6b27d21d3232c0f5773e294fd911ec Mon Sep 17 00:00:00 2001 From: Erick Zanardo Date: Sat, 29 Aug 2020 11:53:09 -0300 Subject: [PATCH 8/9] Adding missing recordFps to particle example --- doc/examples/particles/lib/main.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/examples/particles/lib/main.dart b/doc/examples/particles/lib/main.dart index d05c39bd3e8..f02a0f08e6d 100644 --- a/doc/examples/particles/lib/main.dart +++ b/doc/examples/particles/lib/main.dart @@ -51,6 +51,9 @@ class MyGame extends BaseGame { Offset cellSize; Offset halfCellSize; + @override + bool recordFps() => true; + MyGame({ Size screenSize, }) { From 9312d1472fe4b1e444e5f2a16459e02e2f2eb5a7 Mon Sep 17 00:00:00 2001 From: Erick Zanardo Date: Mon, 31 Aug 2020 22:15:44 -0300 Subject: [PATCH 9/9] Bumping version --- CHANGELOG.md | 4 ++-- doc/README.md | 2 +- pubspec.yaml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75f01acaa71..b500173deb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,8 @@ # CHANGELOG -## [next] +## 0.26.0 - Improving Flame image auto cache - - fix bug in the Box2DGame's add and addLater method , when the Component extends BodyComponent and mixin HasGameRef or other mixins ,the mixins will not be set correctly + - Fix bug in the Box2DGame's add and addLater method , when the Component extends BodyComponent and mixin HasGameRef or other mixins ,the mixins will not be set correctly ## 0.25.0 - Externalizing Tiled support to its own package `flame_tiled` diff --git a/doc/README.md b/doc/README.md index 72d386751bd..f9d9e789321 100644 --- a/doc/README.md +++ b/doc/README.md @@ -18,7 +18,7 @@ Put the pub package as your dependency by dropping the following in your `pubspe ```yaml dependencies: - flame: ^0.25.0 + flame: ^0.26.0 ``` And start using it! diff --git a/pubspec.yaml b/pubspec.yaml index f60411642b8..02354e28990 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flame description: A minimalist Flutter game engine, provides a nice set of somewhat independent modules you can choose from. -version: 0.25.0 +version: 0.26.0 homepage: https://github.com/flame-engine/flame dependencies: