Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tejainece/flutter_sprite
Spritesheet support for Flutter
https://github.com/tejainece/flutter_sprite
Last synced: about 2 months ago
JSON representation
Spritesheet support for Flutter
- Host: GitHub
- URL: https://github.com/tejainece/flutter_sprite
- Owner: tejainece
- License: bsd-3-clause
- Created: 2021-01-23T13:14:16.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2024-09-10T16:57:21.000Z (4 months ago)
- Last Synced: 2024-09-10T18:58:01.366Z (4 months ago)
- Language: Dart
- Size: 447 KB
- Stars: 4
- Watchers: 3
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# flutter_sprite
## Usage
### Spritesheet
Spritesheet can be loaded from the flutter assets. Make sure you put the spritesheet json spec and the images in the
assets directory.### Loading the sprite
Use `Sprite.load` to load a sprite from the flutter assets.
```dart
Future loadSprite() async {
Sprite sprite = await Sprite.load('asset/swords_man/sprite.json');
}
```### Displaying and animating the sprite
```dart
Widget build(BuildContext context) async {
return SpriteWidget(sprite);
}
```### Control the animation
The sprite playback can be paused and restarted at any time using `SpriteController`. `SpriteController` is obtained
using `onReady` callback.```dart
Widget build(BuildContext context) async {
return SpriteWidget(sprite, onReady: (controller) {
Timer(Duration(seconds: 10), () {
controller.pause();Timer(Duration(seconds: 10), () {
controller.play();
});
});
});
}
```## TODO
+ [ ] Layered sprite
+ [ ] Play from specific point
+ [ ] Animation controls to debug animations