2021-09-08 21:44:12 +00:00
|
|
|
import 'package:firo_runner/moving_object.dart';
|
2021-09-04 04:17:12 +00:00
|
|
|
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(
|
2021-09-09 22:56:26 +00:00
|
|
|
amount: 12,
|
2021-09-04 04:17:12 +00:00
|
|
|
stepTime: 0.1,
|
|
|
|
textureSize: Vector2(512, 512),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
sprite = SpriteAnimationGroupComponent(
|
|
|
|
animations: {
|
|
|
|
CoinState.normal: normal,
|
|
|
|
},
|
|
|
|
current: CoinState.normal,
|
|
|
|
);
|
|
|
|
|
2021-09-04 22:56:08 +00:00
|
|
|
sprite.changePriorityWithoutResorting(COIN_PRIORITY);
|
|
|
|
|
2021-09-08 19:27:06 +00:00
|
|
|
var platform = gameRef.platformHolder.l1;
|
2021-09-04 04:17:12 +00:00
|
|
|
|
|
|
|
setSize(
|
2021-09-08 21:44:12 +00:00
|
|
|
gameRef.blockSize * (platform.width / platform.height / 14),
|
|
|
|
gameRef.blockSize * (platform.width / platform.height / 14),
|
2021-09-04 04:17:12 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|