mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-02 11:43:19 +08:00
update docs
This commit is contained in:
@ -92,24 +92,22 @@ it also can receive a FlareController that can play multiple animations and cont
|
||||
import 'package:flame_flare/flame_flare.dart';
|
||||
|
||||
// your implementation of FlareController
|
||||
class BurrController extends FlareControls {
|
||||
class WashingtonController extends FlareControls {
|
||||
|
||||
ActorNode sinnersNode;
|
||||
ActorNode saintsNode;
|
||||
ActorNode rightHandNode;
|
||||
|
||||
void initialize(FlutterActorArtboard artboard) {
|
||||
super.initialize(artboard);
|
||||
|
||||
// get flare node
|
||||
sinnersNode = artboard.getNode("sinners");
|
||||
saintsNode = artboard.getNode("saints");
|
||||
rightHand = artboard.getNode("right_hand");
|
||||
}
|
||||
}
|
||||
|
||||
final fileName = "assets/wait_for_it.flr";
|
||||
final fileName = "assets/george_washington.flr";
|
||||
final width = 1776;
|
||||
final height = 1804;
|
||||
final controller = BurrController();
|
||||
final controller = WashingtonController(); //instantiate controller
|
||||
|
||||
FlareActorComponent flareAnimation = FlareActorComponent(
|
||||
fileName,
|
||||
@ -123,13 +121,13 @@ it also can receive a FlareController that can play multiple animations and cont
|
||||
add(flareAnimation);
|
||||
|
||||
// to play an animation
|
||||
controller.play("theodosia");
|
||||
controller.play("rise_up");
|
||||
|
||||
// you can add another animation to play at the same time
|
||||
controller.play("shes_mine");
|
||||
controller.play("close_door_way_out");
|
||||
|
||||
// also, get a flare node and modify it
|
||||
controller.sinnersNode.rotation = math.pi;
|
||||
controller.rightHandNode.rotation = math.pi;
|
||||
```
|
||||
|
||||
You can also change the current playing animation using the `updateAnimation` method.
|
||||
|
||||
@ -4,7 +4,6 @@ import 'dart:ui';
|
||||
|
||||
import 'package:flame/animation.dart';
|
||||
import 'package:flame/components/component.dart';
|
||||
import 'package:flame/flare_animation.dart';
|
||||
import 'package:flame/particles/circle_particle.dart';
|
||||
import 'package:flame/particles/composed_particle.dart';
|
||||
import 'package:flame/particles/curved_particle.dart';
|
||||
@ -18,7 +17,6 @@ import 'package:flame/particles/accelerated_particle.dart';
|
||||
import 'package:flame/particles/paint_particle.dart';
|
||||
import 'package:flame/particles/animation_particle.dart';
|
||||
import 'package:flame/particles/component_particle.dart';
|
||||
import 'package:flame/particles/flare_particle.dart';
|
||||
import 'package:flame/flame.dart';
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:flame/time.dart' as flame_time;
|
||||
@ -52,11 +50,9 @@ class MyGame extends BaseGame {
|
||||
|
||||
Offset cellSize;
|
||||
Offset halfCellSize;
|
||||
FlareAnimation flareAnimation;
|
||||
|
||||
MyGame({
|
||||
Size screenSize,
|
||||
this.flareAnimation,
|
||||
Size screenSize
|
||||
}) {
|
||||
size = screenSize;
|
||||
cellSize = Offset(size.width / gridSize, size.height / gridSize);
|
||||
@ -461,36 +457,6 @@ class MyGame extends BaseGame {
|
||||
);
|
||||
}
|
||||
|
||||
/// [FlareParticle] renders fiven [FlareAnimation] inside
|
||||
/// as you can see, animation could be reused across
|
||||
/// different particles.
|
||||
Particle flareParticle() {
|
||||
final flare = ComposedParticle(children: <Particle>[
|
||||
// Circle Particle for background
|
||||
CircleParticle(
|
||||
paint: Paint()..color = Colors.white12,
|
||||
radius: flareAnimation.width / 2),
|
||||
FlareParticle(flare: flareAnimation),
|
||||
]);
|
||||
|
||||
final List<Offset> corners = [
|
||||
-halfCellSize,
|
||||
halfCellSize,
|
||||
];
|
||||
|
||||
return RotatingParticle(
|
||||
to: pi,
|
||||
child: Particle.generate(
|
||||
count: 2,
|
||||
generator: (i) => MovingParticle(
|
||||
to: corners[i] * .4,
|
||||
curve: SineCurve(),
|
||||
child: flare,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// [Particle] base class exposes a number
|
||||
/// of convenience wrappers to make positioning.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user