Adding destoryOnFinish flag to AnimationComponent

This commit is contained in:
Erick Zanardo
2019-06-28 18:11:38 -03:00
parent 006a20f99f
commit b50efcb3a5
2 changed files with 27 additions and 5 deletions

View File

@ -5,8 +5,9 @@ import 'package:flame/animation.dart';
class AnimationComponent extends PositionComponent {
Animation animation;
bool destroyOnFinish;
AnimationComponent(double width, double height, this.animation) {
AnimationComponent(double width, double height, this.animation, { this.destroyOnFinish = false }) {
this.width = width;
this.height = height;
}
@ -22,6 +23,8 @@ class AnimationComponent extends PositionComponent {
double textureY = 0.0,
double textureWidth,
double textureHeight,
this.destroyOnFinish = false,
}) {
this.width = width;
this.height = height;
@ -38,6 +41,9 @@ class AnimationComponent extends PositionComponent {
@override
bool loaded() => animation.loaded();
@override
bool destroy() => destroyOnFinish && animation.isLastFrame;
@override
void render(Canvas canvas) {
prepareCanvas(canvas);