mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-03 04:18:25 +08:00
fix: doc/examples/particles, added web to .gitignore feat: doc/examples/particles, added more examples, refactor: Particle does not extend Component refactor: Particle subclasses in separate folder refactor: ParticleComponent is now simple container fix: SingleChildParticle, asserts for child existing feat: AnimationParticle for Flame Animation feat: ComponentParticle for Flame Component feat: SpriteParticle for Flame Sprite
33 lines
630 B
Dart
33 lines
630 B
Dart
import 'dart:ui';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import '../flare_animation.dart';
|
|
import '../particle.dart';
|
|
|
|
class FlareParticle extends Particle {
|
|
final FlareAnimation flare;
|
|
|
|
FlareParticle({
|
|
@required this.flare,
|
|
double lifespan,
|
|
Duration duration,
|
|
}) : super(
|
|
lifespan: lifespan,
|
|
duration: duration,
|
|
);
|
|
|
|
@override
|
|
void render(Canvas canvas) {
|
|
canvas.save();
|
|
canvas.translate(-flare.width / 2, -flare.height / 2);
|
|
flare.render(canvas);
|
|
canvas.restore();
|
|
}
|
|
|
|
@override
|
|
void update(double dt) {
|
|
super.update(dt);
|
|
flare.update(dt);
|
|
}
|
|
} |