mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-01 10:38:17 +08:00
Enabling direct import of Sprite and SpriteAnimation (#652)
* Enabling direct import of Sprite and SpriteAnimation * Renan follow up * Fixing spritesheet exmaple Co-authored-by: Erick Zanardo <erickzanardoo@gmail.com>
This commit is contained in:
@ -5,6 +5,7 @@
|
|||||||
- Moving render functions from `util.dart` to `extensions/canvas.dart`
|
- Moving render functions from `util.dart` to `extensions/canvas.dart`
|
||||||
- Adapting ParallaxComponent contructors to match the pattern followed on other components
|
- Adapting ParallaxComponent contructors to match the pattern followed on other components
|
||||||
- Adapting SpriteBatchComponent constructors to match the pattern used on other components
|
- Adapting SpriteBatchComponent constructors to match the pattern used on other components
|
||||||
|
- Enabling direct import of Sprite and SpriteAnimation
|
||||||
- Renamed `Composition` to `ImageComposition` to prevent confusion with the composition component
|
- Renamed `Composition` to `ImageComposition` to prevent confusion with the composition component
|
||||||
- Added `rotation` and `anchor` arguments to `ImageComposition.add`
|
- Added `rotation` and `anchor` arguments to `ImageComposition.add`
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import 'package:flame/components.dart';
|
import 'package:flame/components.dart';
|
||||||
import 'package:flame/game.dart';
|
import 'package:flame/game.dart';
|
||||||
import 'package:flame/gestures.dart';
|
import 'package:flame/gestures.dart';
|
||||||
import 'package:flame/spritesheet.dart';
|
import 'package:flame/sprite.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart' hide Image;
|
import 'package:flutter/material.dart' hide Image;
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import 'package:flame/components.dart' hide Timer;
|
|||||||
import 'package:flame/timer.dart' as flame_timer;
|
import 'package:flame/timer.dart' as flame_timer;
|
||||||
import 'package:flame/game.dart';
|
import 'package:flame/game.dart';
|
||||||
import 'package:flame/particles.dart';
|
import 'package:flame/particles.dart';
|
||||||
import 'package:flame/spritesheet.dart';
|
import 'package:flame/sprite.dart';
|
||||||
import 'package:flutter/material.dart' hide Image;
|
import 'package:flutter/material.dart' hide Image;
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import 'dart:math';
|
|||||||
import 'package:flame/components.dart';
|
import 'package:flame/components.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flame/game.dart';
|
import 'package:flame/game.dart';
|
||||||
import 'package:flame/sprite_batch.dart';
|
import 'package:flame/sprite.dart';
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:flame/sprite_batch.dart';
|
import 'package:flame/sprite.dart';
|
||||||
import 'package:flame/components.dart';
|
import 'package:flame/components.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flame/game.dart';
|
import 'package:flame/game.dart';
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import 'package:flame/components.dart';
|
import 'package:flame/components.dart';
|
||||||
import 'package:flame/game.dart';
|
import 'package:flame/game.dart';
|
||||||
import 'package:flame/spritesheet.dart';
|
import 'package:flame/sprite.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import 'package:flame/extensions.dart';
|
|||||||
import 'package:flame/widgets.dart';
|
import 'package:flame/widgets.dart';
|
||||||
import 'package:flutter/material.dart' hide Animation;
|
import 'package:flutter/material.dart' hide Animation;
|
||||||
import 'package:flame/flame.dart';
|
import 'package:flame/flame.dart';
|
||||||
import 'package:flame/spritesheet.dart';
|
import 'package:flame/sprite.dart';
|
||||||
import 'package:dashbook/dashbook.dart';
|
import 'package:dashbook/dashbook.dart';
|
||||||
|
|
||||||
Anchor parseAnchor(String name) {
|
Anchor parseAnchor(String name) {
|
||||||
|
|||||||
@ -45,6 +45,7 @@ Example:
|
|||||||
|
|
||||||
```dart
|
```dart
|
||||||
import 'package:flame/flame.dart';
|
import 'package:flame/flame.dart';
|
||||||
|
import 'package:flame/sprite.dart';
|
||||||
|
|
||||||
// inside an async context
|
// inside an async context
|
||||||
Image image = await Flame.images.load('player.png');
|
Image image = await Flame.images.load('player.png');
|
||||||
@ -314,7 +315,7 @@ You can see a full example of the SpriteSheet class [here](https://github.com/fl
|
|||||||
Sprite sheets are big images with several frames of the same sprite on it and is a very good way to organize and keep your animations stored. Flame provides a very simple utility class to deal with SpriteSheets, with it you can load your sprite sheet image and extract animations from it. Below is a very simple example of how to use it:
|
Sprite sheets are big images with several frames of the same sprite on it and is a very good way to organize and keep your animations stored. Flame provides a very simple utility class to deal with SpriteSheets, with it you can load your sprite sheet image and extract animations from it. Below is a very simple example of how to use it:
|
||||||
|
|
||||||
```dart
|
```dart
|
||||||
import 'package:flame/spritesheet.dart';
|
import 'package:flame/sprite.dart';
|
||||||
|
|
||||||
final spritesheet = SpriteSheet(
|
final spritesheet = SpriteSheet(
|
||||||
image: imageInstance,
|
image: imageInstance,
|
||||||
|
|||||||
4
lib/sprite.dart
Normal file
4
lib/sprite.dart
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export 'src/sprite.dart';
|
||||||
|
export 'src/sprite_animation.dart';
|
||||||
|
export 'src/sprite_batch.dart';
|
||||||
|
export 'src/spritesheet.dart';
|
||||||
@ -1 +0,0 @@
|
|||||||
export 'src/sprite_batch.dart';
|
|
||||||
@ -1 +0,0 @@
|
|||||||
export 'src/spritesheet.dart';
|
|
||||||
Reference in New Issue
Block a user