diff --git a/doc/examples/animations/lib/main.dart b/doc/examples/animations/lib/main.dart index e9c2df5fa..8e8dbd548 100644 --- a/doc/examples/animations/lib/main.dart +++ b/doc/examples/animations/lib/main.dart @@ -56,7 +56,7 @@ class MyGame extends BaseGame with TapDetector { add(reversedAnimationComponent); } - void addAnimation(double x, double y) { + void addAnimation(Vector2 position) { final size = Vector2(291, 178); final animationComponent = SpriteAnimationComponent.fromFrameData( @@ -72,14 +72,14 @@ class MyGame extends BaseGame with TapDetector { removeOnFinish: true, ); - animationComponent.position = Vector2(x, y); + animationComponent.position = position; animationComponent.position = animationComponent.position - size / 2; add(animationComponent); } @override void onTapDown(TapDownDetails evt) { - addAnimation(evt.globalPosition.dx, evt.globalPosition.dy); + addAnimation(Vector2(evt.globalPosition.dx, evt.globalPosition.dy)); } MyGame(Vector2 screenSize) { diff --git a/doc/images.md b/doc/images.md index 839d66f87..58736ed24 100644 --- a/doc/images.md +++ b/doc/images.md @@ -109,7 +109,7 @@ You could also specify the coordinates in the original image where the sprite is ```dart final image = await loadImage(); - Sprite playerFrame = Sprite( + final playerFrame = Sprite( image, srcPosition: Vector2(32.0, 0), srcSize: Vector2(16.0, 16.0), @@ -200,7 +200,7 @@ A better alternative to generate a list of sprites is to use the `fromFrameData` ```dart const amountOfFrames = 8; - SpriteAnimation a = SpriteAnimation.fromFrameData( + final a = SpriteAnimation.fromFrameData( imageInstance, SpriteAnimationFrame.sequenced( amount: amountOfFrames, @@ -212,7 +212,7 @@ A better alternative to generate a list of sprites is to use the `fromFrameData` This constructor makes creating an Animation very easy using sprite sheets. -In which you pass the image instance, and the frame data, which contains some parameters which can be used to describe the animation. Check the documentation on the constructors available on `SpriteAnimationFrameData` class to see all the parameters. +In the constructor you pass an image instance and the frame data, which contains some parameters that can be used to describe the animation. Check the documentation on the constructors available on `SpriteAnimationFrameData` class to see all the parameters. If you use Aseprite for your animations, Flame does provide some support for Aseprite animation's JSON data. To use this feature you will need to export the Sprite Sheet's JSON data, and use something like the following snippet: diff --git a/lib/components/sprite_animation_component.dart b/lib/components/sprite_animation_component.dart index 3c48f27a2..f800359a5 100644 --- a/lib/components/sprite_animation_component.dart +++ b/lib/components/sprite_animation_component.dart @@ -25,7 +25,7 @@ class SpriteAnimationComponent extends PositionComponent { /// Creates a component with an empty animation which can be set later SpriteAnimationComponent.empty(); - /// Creates a SpriteAnimationComponent from a [size], an [image] and [data], check [SpriteAnimationData] for more info on the available options. + /// Creates a SpriteAnimationComponent from a [size], an [image] and [data]. Check [SpriteAnimationData] for more info on the available options. /// /// Optionally [removeOnFinish] can be set to true to have this component be auto removed from the [BaseGame] when the animation is finished. SpriteAnimationComponent.fromFrameData( diff --git a/lib/game/game.dart b/lib/game/game.dart index b9c66ca2a..51f890524 100644 --- a/lib/game/game.dart +++ b/lib/game/game.dart @@ -13,7 +13,6 @@ import '../extensions/vector2.dart'; import '../keyboard.dart'; import '../sprite.dart'; import '../sprite_animation.dart'; -import 'widget_builder.dart'; /// Represents a generic game. /// diff --git a/lib/sprite_animation.dart b/lib/sprite_animation.dart index 8dd6f3d42..91aa5fba3 100644 --- a/lib/sprite_animation.dart +++ b/lib/sprite_animation.dart @@ -12,7 +12,7 @@ class SpriteAnimationFrameData { final Vector2 srcSize; /// The duration to display it, in seconds. - double stepTime; + final double stepTime; SpriteAnimationFrameData({ @required this.srcPosition,