flame_texturepacker
A flame plugin to import spritesheets generated by TexturePacker
Install from Dart Pub
Include the following to your pubspec.yaml file:
dependencies:
flame_texturepacker: any
Usage
Drop generated spritesheet image into the assets/images/
folder and the spritesheet json into assets/
and link the files in your pubspec.yaml
file:
assets:
- assets/spritesheet.json
- assets/images/spritesheet.png
Import the plugin like this:
import 'package:flame_texturepacker/flame_texturepacker.dart';
Generate a list of Sprite
s from the provided spritesheet:
List<Sprite> sprites = await TexturepackerLoader.fromJSONAtlas('spritesheet.png', 'spritesheet.json');
The list can be used to generate an Animation as well:
Animation anim = Animation.spriteList(
sprites,
stepTime: 0.1,
loop: true,
);
Generate a map of Sprite
s from the provided spritesheet where the key will be the Sprite
filename without extension:
Map<String, Sprite> map = await TexturepackerLoader.fromJSONAtlasAsMap('spritesheet.png', 'spritesheet.json');
Full working example can be found in example folder.