refactor: load ball assets from cache

pull/279/head
RuiAlonso 3 years ago
parent 97193c63f3
commit 5bc3e4d7a3

@ -120,15 +120,21 @@ class Ball<T extends Forge2DGame> extends BodyComponent<T>
} }
class _BallSpriteComponent extends SpriteComponent with HasGameRef { class _BallSpriteComponent extends SpriteComponent with HasGameRef {
_BallSpriteComponent()
: super(
anchor: Anchor.center,
);
@override @override
Future<void> onLoad() async { Future<void> onLoad() async {
await super.onLoad(); await super.onLoad();
final sprite = await gameRef.loadSprite( final sprite = Sprite(
Assets.images.ball.ball.keyName, gameRef.images.fromCache(
Assets.images.ball.ball.keyName,
),
); );
this.sprite = sprite; this.sprite = sprite;
size = sprite.originalSize / 10; size = sprite.originalSize / 10;
anchor = Anchor.center;
} }
} }
@ -147,7 +153,7 @@ class _TurboChargeSpriteAnimationComponent extends SpriteAnimationComponent
Future<void> onLoad() async { Future<void> onLoad() async {
await super.onLoad(); await super.onLoad();
final spriteSheet = await gameRef.images.load( final spriteSheet = gameRef.images.fromCache(
Assets.images.ball.flameEffect.keyName, Assets.images.ball.flameEffect.keyName,
); );

Loading…
Cancel
Save