flame_rive 1.10.6 copy "flame_rive: ^1.10.6" to clipboard
flame_rive: ^1.10.6 copied to clipboard

Rive support for the Flame game engine. This uses the rive package and provides wrappers and components to be used inside Flame.

example/lib/main.dart

import 'package:flame/events.dart';
import 'package:flame/game.dart';
import 'package:flame_rive/flame_rive.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const GameWidget.controlled(gameFactory: RiveExampleGame.new));
}

class RiveExampleGame extends FlameGame {
  @override
  Future<void> onLoad() async {
    final skillsArtboard =
        await loadArtboard(RiveFile.asset('assets/skills.riv'));
    add(SkillsAnimationComponent(skillsArtboard));
  }
}

class SkillsAnimationComponent extends RiveComponent with TapCallbacks {
  SkillsAnimationComponent(Artboard artboard) : super(artboard: artboard);

  SMIInput<double>? _levelInput;

  @override
  void onGameResize(Vector2 size) {
    super.onGameResize(size);
    this.size = size;
  }

  @override
  void onLoad() {
    final controller = StateMachineController.fromArtboard(
      artboard,
      "Designer's Test",
    );
    if (controller != null) {
      artboard.addController(controller);
      _levelInput = controller.findInput<double>('Level');
      _levelInput?.value = 0;
    }
  }

  @override
  void onTapDown(TapDownEvent event) {
    final levelInput = _levelInput;
    if (levelInput == null) {
      return;
    }
    levelInput.value = (levelInput.value + 1) % 3;
  }
}
32
likes
150
points
1.49k
downloads

Publisher

verified publisherflame-engine.org

Weekly Downloads

Rive support for the Flame game engine. This uses the rive package and provides wrappers and components to be used inside Flame.

Repository (GitHub)
View/report issues
Contributing

Topics

#flame #rive #animations

Documentation

API reference

Funding

Consider supporting this project:

opencollective.com
github.com
patreon.com

License

MIT (license)

Dependencies

flame, flutter, rive

More

Packages that depend on flame_rive