mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-03 04:18:25 +08:00
* Initial commit * Flare support * Adding docs for FlareAnimation * Some organization fixes on Flare example game * Adding changelog entry * Fixing lint * Adding FlareComponent * PR changes * PR suggestions and linting
38 lines
834 B
Dart
38 lines
834 B
Dart
import 'dart:ui';
|
|
|
|
import 'component.dart';
|
|
import 'package:flame/flare_animation.dart';
|
|
|
|
class FlareComponent extends PositionComponent {
|
|
FlareAnimation _flareAnimation;
|
|
|
|
FlareComponent(
|
|
String fileName, String animation, double width, double height) {
|
|
FlareAnimation.load(fileName).then((loadedFlareAnimation) {
|
|
_flareAnimation = loadedFlareAnimation;
|
|
|
|
_flareAnimation.updateAnimation(animation);
|
|
_flareAnimation.width = width;
|
|
_flareAnimation.height = height;
|
|
});
|
|
}
|
|
|
|
@override
|
|
bool loaded() => _flareAnimation != null;
|
|
|
|
@override
|
|
void render(Canvas canvas) {
|
|
_flareAnimation.render(canvas);
|
|
}
|
|
|
|
@override
|
|
void update(double dt) {
|
|
if (_flareAnimation != null) {
|
|
_flareAnimation.x = x;
|
|
_flareAnimation.y = y;
|
|
|
|
_flareAnimation.update(dt);
|
|
}
|
|
}
|
|
}
|