2021-09-08 21:44:12 +00:00
|
|
|
import 'package:firo_runner/moving_object.dart';
|
2021-09-04 22:56:08 +00:00
|
|
|
import 'package:firo_runner/main.dart';
|
|
|
|
import 'package:flame/components.dart';
|
|
|
|
|
|
|
|
enum WireState { normal }
|
|
|
|
|
|
|
|
class Wire extends MovingObject {
|
|
|
|
Wire(MyGame gameRef) : super(gameRef) {
|
|
|
|
var wire = gameRef.wireHolder.getWire();
|
|
|
|
SpriteAnimation normal = SpriteAnimation.fromFrameData(
|
|
|
|
wire,
|
|
|
|
SpriteAnimationData.sequenced(
|
2021-09-07 20:45:42 +00:00
|
|
|
amount: 12,
|
|
|
|
stepTime: 0.05,
|
2021-09-04 22:56:08 +00:00
|
|
|
textureSize: Vector2(512, 512),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
sprite = SpriteAnimationGroupComponent(
|
|
|
|
animations: {
|
|
|
|
WireState.normal: normal,
|
|
|
|
},
|
|
|
|
current: WireState.normal,
|
|
|
|
);
|
|
|
|
|
|
|
|
sprite.changePriorityWithoutResorting(WIRE_PRIORITY);
|
|
|
|
|
|
|
|
setSize(
|
|
|
|
gameRef.blockSize,
|
|
|
|
gameRef.blockSize,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
double getRightEnd() {
|
|
|
|
return sprite.position.x + sprite.width;
|
|
|
|
}
|
|
|
|
|
|
|
|
void remove() {
|
|
|
|
sprite.remove();
|
|
|
|
}
|
|
|
|
}
|