flame_texturepacker 4.1.2 copy "flame_texturepacker: ^4.1.2" to clipboard
flame_texturepacker: ^4.1.2 copied to clipboard

A simple plugin for the Flame Engine to import spritesheets generated by the TexturePacker tool.

flame

A flame plugin to import sprite sheets generated by Gdx Texture Packer and Code & Web Texture Packer


flame_texturepacker #

TexturePacker is a tool to create efficient sprite sheets. This plugin allows you to import sprite sheets generated by Gdx Texture Packer and Code and Web Texture Packer into your Flame game.

Install from Pub #

flutter pub add flame_texturepacker

Usage #

Asset Storage #

Drop generated atlas file and sprite sheet images into the assets/images/ and link the files in your pubspec.yaml file:

 assets:
   - assets/images/atlas_map.atlas
   - assets/images/sprite_sheet1.png

Import the plugin like this:

import 'package:flame_texturepacker/flame_texturepacker.dart';

Load the TextureAtlas passing the path of the sprite sheet atlas file:

final atlas = await atlasFromAssets('atlas_map.atlas');

File Storage #

If you are using file storage, grab your atlas file like this:

final documentsPath = (await getApplicationDocumentsDirectory()).path;
final atlas = await atlasFromStorage('$documentsPath/atlas_map.atlas');

Get a list of sprites ordered by their index, you can use the list to generate an animation:

final spriteList = atlas.findSpritesByName('robot_walk');

final animation = SpriteAnimation.spriteList(
 spriteList,
 stepTime: 0.1,
 loop: true,
);

Get individual sprites by name:

final jumpSprite = atlas.findSpriteByName('robot_jump')!;
final fallSprite = atlas.findSpriteByName('robot_fall')!;
final idleSprite = atlas.findSpriteByName('robot_idle')!;

Supported Features #

Feature Supported
Allow Rotation YES
Multiple Pages YES
Use indices YES
Strip whitespace X NO
Strip whitespace Y NO

Example #

Full working example can be found in example folder.

Note: Sprites used in this example can be found OpenGameArt here.

Credits #

Thanks to Jonas Fröber for the original implementation. Thanks to Gnarhard for the feature to build the atlas file from a device's storage.

13
likes
160
pub points
82%
popularity

Publisher

verified publisherflame-engine.org

A simple plugin for the Flame Engine to import spritesheets generated by the TexturePacker tool.

Repository (GitHub)
View/report issues
Contributing

Topics

#flame #spritesheet

Documentation

API reference

Funding

Consider supporting this project:

opencollective.com
github.com
patreon.com

License

MIT (license)

Dependencies

collection, flame, flutter

More

Packages that depend on flame_texturepacker