mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-03 12:28:03 +08:00
Adding destoryOnFinish flag to AnimationComponent
This commit is contained in:
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user