Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Brixto/flame_texturepacker
https://github.com/Brixto/flame_texturepacker
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/Brixto/flame_texturepacker
- Owner: Brixto
- License: mit
- Created: 2020-01-14T15:19:31.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-01-21T11:00:11.000Z (11 months ago)
- Last Synced: 2024-08-02T07:07:16.342Z (4 months ago)
- Language: Dart
- Size: 514 KB
- Stars: 22
- Watchers: 3
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-flame - flame_texturepacker - Import spritesheets from TexturePacker. By [Brixto](https://github.com/Brixto) (Plugins & Libraries / Examples)
README
# Note: This repostitory has moved to the [Flame monorepo](https://github.com/flame-engine/flame/tree/main/packages/flame_texturepacker)
---
# flame_texturepacker
A flame plugin to import sprite sheets generated by [Gdx Texture Packer][2] and [Code and Web Texture Packer][1]
## Install from Dart Pub
Include the following to your pubspec.yaml file:
```yaml
dependencies:
flame_texturepacker: any
```
## Usage
Drop generated atlas file and sprite sheet images into the `assets/` and link the files in your `pubspec.yaml` file:
```yaml
assets:
- assets/spriteSheet.atlas
- assets/spriteSheet.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:```Dart
final atlas = await fromAtlas('FlameAtlasMap.atlas');
```Get a list of sprites ordered by their index, you can use the list to generate an animation:
```Dart
final spriteList = atlas.findSpritesByName('robot_walk');final animation = SpriteAnimation.spriteList(
spriteList,
stepTime: 0.1,
loop: true,
);
```Get individual sprites by name:
```Dart
final jumpSprite = atlas.findSpriteByName('robot_jump')!;
final fallSprite = atlas.findSpriteByName('robot_fall')!;
final idleSprite = atlas.findSpriteByName('robot_idle')!;
```Full working example can be found in [example folder][3].
Note: Sprites used in this example can be found OpenGameArt [here][4].
[1]: https://www.codeandweb.com/texturepacker 'Code & Web Texture Packer'
[2]: https://github.com/crashinvaders/gdx-texture-packer-gui 'Gdx Texture Packer'
[3]: /example/lib/main.dart 'Full working example'
[4]: https://opengameart.org/content/toon-characters-1 'Robot sprite'