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';
|
import 'package:flame_flare/flame_flare.dart';
|
||||||
|
|
||||||
// your implementation of FlareController
|
// your implementation of FlareController
|
||||||
class BurrController extends FlareControls {
|
class WashingtonController extends FlareControls {
|
||||||
|
|
||||||
ActorNode sinnersNode;
|
ActorNode rightHandNode;
|
||||||
ActorNode saintsNode;
|
|
||||||
|
|
||||||
void initialize(FlutterActorArtboard artboard) {
|
void initialize(FlutterActorArtboard artboard) {
|
||||||
super.initialize(artboard);
|
super.initialize(artboard);
|
||||||
|
|
||||||
// get flare node
|
// get flare node
|
||||||
sinnersNode = artboard.getNode("sinners");
|
rightHand = artboard.getNode("right_hand");
|
||||||
saintsNode = artboard.getNode("saints");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final fileName = "assets/wait_for_it.flr";
|
final fileName = "assets/george_washington.flr";
|
||||||
final width = 1776;
|
final width = 1776;
|
||||||
final height = 1804;
|
final height = 1804;
|
||||||
final controller = BurrController();
|
final controller = WashingtonController(); //instantiate controller
|
||||||
|
|
||||||
FlareActorComponent flareAnimation = FlareActorComponent(
|
FlareActorComponent flareAnimation = FlareActorComponent(
|
||||||
fileName,
|
fileName,
|
||||||
@ -123,13 +121,13 @@ it also can receive a FlareController that can play multiple animations and cont
|
|||||||
add(flareAnimation);
|
add(flareAnimation);
|
||||||
|
|
||||||
// to play an animation
|
// to play an animation
|
||||||
controller.play("theodosia");
|
controller.play("rise_up");
|
||||||
|
|
||||||
// you can add another animation to play at the same time
|
// 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
|
// 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.
|
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/animation.dart';
|
||||||
import 'package:flame/components/component.dart';
|
import 'package:flame/components/component.dart';
|
||||||
import 'package:flame/flare_animation.dart';
|
|
||||||
import 'package:flame/particles/circle_particle.dart';
|
import 'package:flame/particles/circle_particle.dart';
|
||||||
import 'package:flame/particles/composed_particle.dart';
|
import 'package:flame/particles/composed_particle.dart';
|
||||||
import 'package:flame/particles/curved_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/paint_particle.dart';
|
||||||
import 'package:flame/particles/animation_particle.dart';
|
import 'package:flame/particles/animation_particle.dart';
|
||||||
import 'package:flame/particles/component_particle.dart';
|
import 'package:flame/particles/component_particle.dart';
|
||||||
import 'package:flame/particles/flare_particle.dart';
|
|
||||||
import 'package:flame/flame.dart';
|
import 'package:flame/flame.dart';
|
||||||
import 'package:flame/game.dart';
|
import 'package:flame/game.dart';
|
||||||
import 'package:flame/time.dart' as flame_time;
|
import 'package:flame/time.dart' as flame_time;
|
||||||
@ -52,11 +50,9 @@ class MyGame extends BaseGame {
|
|||||||
|
|
||||||
Offset cellSize;
|
Offset cellSize;
|
||||||
Offset halfCellSize;
|
Offset halfCellSize;
|
||||||
FlareAnimation flareAnimation;
|
|
||||||
|
|
||||||
MyGame({
|
MyGame({
|
||||||
Size screenSize,
|
Size screenSize
|
||||||
this.flareAnimation,
|
|
||||||
}) {
|
}) {
|
||||||
size = screenSize;
|
size = screenSize;
|
||||||
cellSize = Offset(size.width / gridSize, size.height / gridSize);
|
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
|
/// [Particle] base class exposes a number
|
||||||
/// of convenience wrappers to make positioning.
|
/// of convenience wrappers to make positioning.
|
||||||
///
|
///
|
||||||
|
|||||||
Reference in New Issue
Block a user