From b3678d893363ddd520c00584f29defb57ea1484f Mon Sep 17 00:00:00 2001 From: RuiAlonso Date: Fri, 22 Apr 2022 14:37:07 +0200 Subject: [PATCH] refactor: load dino walls assets from cache --- .../lib/src/components/dino_walls.dart | 12 ++++++++---- test/game/pinball_game_test.dart | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/pinball_components/lib/src/components/dino_walls.dart b/packages/pinball_components/lib/src/components/dino_walls.dart index 2790ec20..49ad8a1c 100644 --- a/packages/pinball_components/lib/src/components/dino_walls.dart +++ b/packages/pinball_components/lib/src/components/dino_walls.dart @@ -106,8 +106,10 @@ class _DinoTopWallSpriteComponent extends SpriteComponent with HasGameRef { @override Future onLoad() async { await super.onLoad(); - final sprite = await gameRef.loadSprite( - Assets.images.dino.dinoLandTop.keyName, + final sprite = Sprite( + gameRef.images.fromCache( + Assets.images.dino.dinoLandTop.keyName, + ), ); this.sprite = sprite; size = sprite.originalSize / 10; @@ -212,8 +214,10 @@ class _DinoBottomWallSpriteComponent extends SpriteComponent with HasGameRef { @override Future onLoad() async { await super.onLoad(); - final sprite = await gameRef.loadSprite( - Assets.images.dino.dinoLandBottom.keyName, + final sprite = Sprite( + gameRef.images.fromCache( + Assets.images.dino.dinoLandBottom.keyName, + ), ); this.sprite = sprite; size = sprite.originalSize / 10; diff --git a/test/game/pinball_game_test.dart b/test/game/pinball_game_test.dart index 4c3dbbfb..6d3f5b33 100644 --- a/test/game/pinball_game_test.dart +++ b/test/game/pinball_game_test.dart @@ -52,6 +52,8 @@ void main() { Assets.images.boundary.bottom.keyName, Assets.images.slingshot.upper.keyName, Assets.images.slingshot.lower.keyName, + Assets.images.dino.dinoLandTop.keyName, + Assets.images.dino.dinoLandBottom.keyName, ]; final flameTester = FlameTester(() => PinballTestGame(assets)); final debugModeFlameTester = FlameTester(() => DebugPinballTestGame(assets));