ssplayer_flame
Flame adapter for
ssplayer_flutter — play a SpriteStudio .ssab
animation inside a FlameGame with a single component.
SpriteStudioComponent plays a SpriteStudioPlayer on Flame's game loop: the
loop supplies the time, and everything else the player does — transport, events,
instance packs, textures — is the same as in a widget.
The documentation covers both packages. The
same pages for this version are in this package's doc/ as Markdown, readable offline: start at
doc/index.md, and the Flame page is doc/guide/flame.md. They are also the Agent Skill
skills/ssplayer-flame-docs/, which dart run skills@ get --all installs into your coding agent's
skills directory (add --agent claude, or another agent, when the project has none yet).
Install
flutter pub add flame ssplayer_flame
ssplayer_flutter and ssruntime_dart come with ssplayer_flame (Installation).
ssplayer_flame re‑exports the entire ssplayer_flutter API, so a single
import 'package:ssplayer_flame/ssplayer_flame.dart'; gives you both
SpriteStudioComponent and SpriteStudioPlayer.
Use
import 'package:flame/components.dart';
import 'package:flame/game.dart';
import 'package:ssplayer_flame/ssplayer_flame.dart';
class MyGame extends FlameGame {
@override
Future<void> onLoad() async {
// Straight from a bundled asset key… reference textures (sibling PNGs)
// resolve from the key's own folder, so no baseAssetDir is needed.
add(SpriteStudioComponent.asset(
'assets/spritestudio/Ringo/Ringo.ssab',
animation: 'wait1',
position: size / 2,
anchor: Anchor.center, // SpriteStudio origins are centered
));
// …or from bytes you already have (e.g. downloaded). With no asset key,
// pass baseAssetDir so the reference textures still resolve:
// add(SpriteStudioComponent(ssab: bytes, baseAssetDir: 'assets'));
}
}
Control playback through the underlying player once it has loaded:
component.player?.pause();
component.player?.setAnimation('run');
component.player?.seek(0);
Notes
- The animation is centered inside the component's box (
size): its world origin lands on the box centre (size / 2in local space), exactly likeSpriteStudioView. With the default zerosizethat is the component'sposition. loopCount/speed/subFrame/animation/autoStartare constructor options; anything finer goes throughcomponent.player.SpriteStudioComponent.assetresolves reference textures (sibling PNGs) from the asset key's own folder — nobaseAssetDirneeded. PassbaseAssetDironly with the bytes constructor (no asset key), or when the textures live in a different folder (a shared atlas). Embedded‑texture packs need nothing.- Web: call
await loadSsRuntime()once beforerunApp, as withssplayer_flutter(a no-op on native); without it nothing draws and nothing fails.
Example
The live Web demos include the Flame one.
Libraries
- ssplayer_flame
- Flame adapter for
ssplayer_flutter.