pogo_rive 0.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • new50

pogo_rive #

Rive (formerly Flare) plugin to the Pogo Game Engine.

Rive is a design tool for vector-based animation. The Flare-Flutter package does the bulk of the work.

Adding the plugin to your Pogo project #

Add the pogo_rive package dependency to your project's pubspec.yaml, for example (check your version number):

dependencies:
  pogo_rive: ^0.1.0

A plugin import is required in addition to the Pogo import in each source file that uses it:

import 'package:pogo/game_engine.dart';
import 'package:pogo_rive/plugin.dart';

RiveComponent class #

The RiveComponent class is a component for use in building a GameEntity. It draws and controls a given Rive animation.

Constructors #

<default>Takes a FlutterActorArtboard by reference.
fromFileTakes a Rive filename (cached or not). Returns a Future.

TODO look into caching

Properties #

animationName *Read-only. Name of the currently playing animation.
artboard *Read-only. Reference to the source FlutterActorArtboard object.
debugColorColor to draw debug-mode information. Default: Color(0xFFFF00FF) magenta.
heightRead-only. Scaled height of the source artboard (the height that will be drawn).
pivot *Pivot point for rotation and anchor point for placement. Default: System.defaultPivot which defaults to Pivot.center.
scale *A scale factor can be provided to adapt the Rive's units to the app's units. Default: 1.0.
unscaledHeightRead-only. Unscaled height of the source artboard.
unscaledWidthRead-only. Unscaled width of the source artboard.
widthRead-only. Scaled width of the source artboard (the width that will be drawn).

* Also is a constructor parameter.

Methods #

loadedReturns whether the animation has loaded yet or not.
renderDraws the Rive, translated by the set Pivot, at the set scale. To execute, call from a GameEnity.update().
setAnimationSets a new animation for playback by animation name.
updateUpdates the animation state. To execute, call from a GameEnity.update().

See the example app.

RivePrefab #

A prefab that implements RiveComponent.

RiveParticle #

An implementation of RiveComponent specific to the built-in ParticleComponent.

See Pogo's particles example app.

Changelog #

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

Unreleased #

  • Look into loading and caching.

0.1.0 - 2020-06-18 #

First commit after removing the plugin from the built-in plugins of Pogo.

Changed #

  • WARNING: Breaking changes!
  • Renamed everything to match Flare's rebranding to Rive. That is: FlareComponent, FlarePrefab, and FlareParticle, are now RiveComponent, RivePrefab, and RiveParticle. Moving this plugin out of Pogo's core seemed as good a time as any to keep up with this questionable rebranding.

example/lib/main.dart

import 'package:pogo/game_engine.dart';
import 'package:pogo_rive/plugin.dart';

// Shows use of RiveComponent, RivePrefab along with single- and double-tap
// functionality.

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Screen.setFullScreen();
  await Screen.setPortrait();

  GestureInitializer.detectSingleTaps = true;
  GestureInitializer.detectDoubleTaps = true;

  Game().debugMode = true;  // turn off if debug visualizations not wanted
  runApp(Game().widget);

  await Screen.waitForStartupSizing();

  MainEntity();
}


class MainEntity extends GameEntity {
  final TextConfig fpsTextConfig = const TextConfig(color: const Color(0xFFFFFFFF));
  TextPrefab fpsText;

  MainEntity() {
    Player(Vector2(Screen.size.width / 2, Screen.size.height / 2));
    fpsText = TextPrefab(
        TextComponent("", textConfig: fpsTextConfig, pivot: Pivot.topLeft),
        position: Vector2(0, 20),
        enabled: false,
    );
  }

  @override
  void update() {
    fpsText.enabled = Game().debugMode;
    if (fpsText.enabled) {
      fpsText.textComponent.text = Game().fps(120).toStringAsFixed(1);
    }
  }
}


class Player extends GameEntity with SingleTapDetector, DoubleTapDetector {
  Size screenSize;

  final List<String> _animations = ["Stand", "Wave", "Jump", "Dance"];
  int _currentAnimation = 0;
  RivePrefab riveAnim;

  bool loaded = false;

  Player(Vector2 position) {
    this.position = position;
    RiveComponent.fromFile("assets/Bob_Minion.flr", "Stand", scale: 0.33)
        .then((comp) => riveAnim = RivePrefab(comp, parent: this))
    ;
  }

  @override
  void onSingleTap() {
    cycleAnimation();
  }

  @override
  void onDoubleTap() {
    riveAnim.scale.x += 0.1;
    riveAnim.scale.y += 0.1;
    riveAnim.position.y += 20;
  }

  void cycleAnimation() {
    if (_currentAnimation == _animations.length - 1) {
      _currentAnimation = 0;
    } else {
      _currentAnimation++;
    }
    riveAnim.riveComponent.setAnimation(_animations[_currentAnimation]);
  }

}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  pogo_rive: ^0.1.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:pogo_rive/plugin.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
50
Learn more about scoring.

We analyzed this package on Jul 3, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform android

Because of import path [package:pogo_rive/plugin.dart, package:pogo_rive/src/prefabs/rive_prefab.dart, package:pogo_rive/src/components/rive_component.dart, package:pogo/game_engine.dart, package:pogo/src/particles/sprite_particle.dart, package:pogo/src/components/sprite_component.dart, package:pogo/src/game/assets_static.dart, package:pogo/src/caches/audio_cache.dart, package:audioplayers/audio_cache.dart, package:path_provider/path_provider.dart, package:path_provider_linux/path_provider_linux.dart] that declares support for platforms: linux

Package does not support Flutter platform ios

Because of import path [package:pogo_rive/plugin.dart, package:pogo_rive/src/prefabs/rive_prefab.dart, package:pogo_rive/src/components/rive_component.dart, package:pogo/game_engine.dart, package:pogo/src/particles/sprite_particle.dart, package:pogo/src/components/sprite_component.dart, package:pogo/src/game/assets_static.dart, package:pogo/src/caches/audio_cache.dart, package:audioplayers/audio_cache.dart, package:path_provider/path_provider.dart, package:path_provider_linux/path_provider_linux.dart] that declares support for platforms: linux

Package does not support Flutter platform linux

Because of import path [package:pogo_rive/plugin.dart, package:pogo_rive/src/prefabs/rive_prefab.dart, package:pogo_rive/src/components/rive_component.dart, package:pogo/game_engine.dart, package:pogo/src/particles/sprite_particle.dart, package:pogo/src/components/sprite_component.dart, package:pogo/src/game/assets_static.dart, package:pogo/src/caches/audio_cache.dart, package:audioplayers/audio_cache.dart] that declares support for platforms: android, ios, macos, web

Package does not support Flutter platform macos

Because of import path [package:pogo_rive/plugin.dart, package:pogo_rive/src/prefabs/rive_prefab.dart, package:pogo_rive/src/components/rive_component.dart, package:pogo/game_engine.dart, package:pogo/src/particles/sprite_particle.dart, package:pogo/src/components/sprite_component.dart, package:pogo/src/game/assets_static.dart, package:pogo/src/caches/audio_cache.dart, package:audioplayers/audio_cache.dart, package:path_provider/path_provider.dart, package:path_provider_linux/path_provider_linux.dart] that declares support for platforms: linux

Package does not support Flutter platform web

Because of import path [package:pogo_rive/plugin.dart, package:pogo_rive/src/prefabs/rive_prefab.dart, package:pogo_rive/src/components/rive_component.dart, package:pogo/game_engine.dart, package:pogo/src/particles/sprite_particle.dart, package:pogo/src/components/sprite_component.dart, package:pogo/src/game/assets_static.dart, package:pogo/src/caches/audio_cache.dart, package:audioplayers/audio_cache.dart, package:path_provider/path_provider.dart] that declares support for platforms: android, ios, linux, macos

Package does not support Flutter platform windows

Because of import path [package:pogo_rive/plugin.dart, package:pogo_rive/src/prefabs/rive_prefab.dart, package:pogo_rive/src/components/rive_component.dart, package:pogo/game_engine.dart, package:pogo/src/particles/sprite_particle.dart, package:pogo/src/components/sprite_component.dart, package:pogo/src/game/assets_static.dart, package:pogo/src/caches/audio_cache.dart, package:audioplayers/audio_cache.dart] that declares support for platforms: android, ios, macos, web

Package not compatible with SDK dart

because of import path [pogo_rive] that is in a package requiring null.

Health suggestions

Format lib/src/components/rive_component.dart.

Run flutter format to format lib/src/components/rive_component.dart.

Format lib/src/particles/rive_particle.dart.

Run flutter format to format lib/src/particles/rive_particle.dart.

Format lib/src/prefabs/rive_prefab.dart.

Run flutter format to format lib/src/prefabs/rive_prefab.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flare_flutter ^2.0.3 2.0.4
flutter 0.0.0
pogo ^0.2.1 0.2.2
Transitive dependencies
audioplayers 0.15.1
charcode 1.1.3
collection 1.14.12 1.14.13
convert 2.1.1
crypto 2.1.5
file 5.2.1
flare_dart 2.3.4
flutter_svg 0.17.4 0.18.0
flutter_web_plugins 0.0.0
intl 0.16.1
meta 1.1.8
path 1.7.0
path_drawing 0.4.1
path_parsing 0.1.4
path_provider 1.6.11
path_provider_linux 0.0.1+2
path_provider_macos 0.0.4+3
path_provider_platform_interface 1.0.2
petitparser 3.0.4
platform 2.2.1
plugin_platform_interface 1.0.2
process 3.0.13
sky_engine 0.0.99
synchronized 2.2.0+1
typed_data 1.1.6 1.2.0
uuid 2.2.0
vector_math 2.0.8
xdg_directories 0.1.0
xml 3.7.0 4.2.0
Dev dependencies
flutter_test
test ^1.9.4