diff --git a/doc/components.md b/doc/components.md index 13de968cd..e02c134b0 100644 --- a/doc/components.md +++ b/doc/components.md @@ -90,6 +90,10 @@ This component wraps an instance of the [FlareAnimation](/doc/images.md#FlareAni add(flareAnimation); ``` +You can also change the current playing animation using the `updateAnimation` method. + +For a working example, check this [source file](/doc/examples/flare/lib/main_component.dart). + ## Composed component A mixin that helps you to make a `Component` wraps other components. It is useful to group visual components through a hierarchy. When implemented, makes every item in its `components` collection field be updated and rendered with the same conditions. @@ -199,4 +203,4 @@ The corners are drawn at the same size, the sides are streched on the side direc Using this, you can get a box/rectangle that expands well to any sizes. This is useful for making panels, dialogs, borders. -Check the example app `nine_tile_box` details on how to use it. \ No newline at end of file +Check the example app `nine_tile_box` details on how to use it. diff --git a/doc/examples/flare/lib/main_component.dart b/doc/examples/flare/lib/main_component.dart index fb47accd2..de99a50d5 100644 --- a/doc/examples/flare/lib/main_component.dart +++ b/doc/examples/flare/lib/main_component.dart @@ -1,10 +1,10 @@ import 'dart:ui'; import 'package:flame/gestures.dart'; -import 'package:flame/flame.dart'; import 'package:flame/game.dart'; import 'package:flame/components/flare_component.dart'; import 'package:flame/text_config.dart'; import 'package:flame/position.dart'; +import 'package:flame/palette.dart'; import 'package:flutter/material.dart'; @@ -16,11 +16,10 @@ void main() { } class MyGame extends BaseGame with TapDetector, DoubleTapDetector { - final TextConfig fpsTextConfig = - const TextConfig(color: const Color(0xFFFFFFFF)); + final TextConfig fpsTextConfig = TextConfig(color: BasicPalette.white.color); final paint = Paint()..color = const Color(0xFFE5E5E5E5); - final List _animations = ["Stand", "Wave", "Jump", "Dance"]; + final List _animations = ['Stand', 'Wave', 'Jump', 'Dance']; int _currentAnimation = 0; FlareComponent flareComponent; @@ -57,7 +56,7 @@ class MyGame extends BaseGame with TapDetector, DoubleTapDetector { } void _start() async { - flareComponent = FlareComponent("assets/Bob_Minion.flr", "Stand", 306, 228); + flareComponent = FlareComponent('assets/Bob_Minion.flr', 'Stand', 306, 228); flareComponent.x = 50; flareComponent.y = 240; add(flareComponent);