firo_runner/lib/coin.dart

36 lines
901 B
Dart

import 'package:firo_runner/moving_object.dart';
import 'package:firo_runner/main.dart';
import 'package:flame/components.dart';
enum CoinState { normal }
class Coin extends MovingObject {
Coin(MyGame gameRef) : super(gameRef) {
var coin = gameRef.coinHolder.getCoin();
SpriteAnimation normal = SpriteAnimation.fromFrameData(
coin,
SpriteAnimationData.sequenced(
amount: 12,
stepTime: 0.1,
textureSize: Vector2(512, 512),
),
);
sprite = SpriteAnimationGroupComponent(
animations: {
CoinState.normal: normal,
},
current: CoinState.normal,
);
sprite.changePriorityWithoutResorting(COIN_PRIORITY);
var platform = gameRef.platformHolder.l1;
setSize(
gameRef.blockSize * (platform.width / platform.height / 14),
gameRef.blockSize * (platform.width / platform.height / 14),
);
}
}