mirror of
https://github.com/flame-engine/flame.git
synced 2025-10-29 07:56:53 +08:00
Removing prefix from FlameSpriteWidget and FlameAnimationWidget
This commit is contained in:
@ -2,8 +2,8 @@
|
||||
|
||||
## [next]
|
||||
- Fixing BaseGame tap detectors issues
|
||||
- Adding FlameSpriteWidget
|
||||
- Adding FlameAnimationWidget
|
||||
- Adding SpriteWidget
|
||||
- Adding AnimationWidget
|
||||
- Upgrade Flutter SVG to fix for flame web
|
||||
- Add linting to all the examples
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
As for Flame 0.22.0 there is a new way to use Animations and Sprites inside your widget tree.
|
||||
|
||||
Flame now includes a widget catalog and inside it you will find `FlameAnimationWidget` and `FlameSpriteWidget`.
|
||||
Flame now includes a widget catalog and inside it you will find `AnimationWidget` and `SpriteWidget`.
|
||||
|
||||
Check the example mentioned on this article to see the updated version.
|
||||
|
||||
|
||||
@ -5,8 +5,8 @@ import 'package:flame/animation.dart' as animation;
|
||||
import 'package:flame/sprite.dart';
|
||||
import 'package:flame/spritesheet.dart';
|
||||
import 'package:flame/position.dart';
|
||||
import 'package:flame/widgets/flame_animation_widget.dart';
|
||||
import 'package:flame/widgets/flame_sprite_widget.dart';
|
||||
import 'package:flame/widgets/animation_widget.dart';
|
||||
import 'package:flame/widgets/sprite_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
Sprite _sprite;
|
||||
@ -91,7 +91,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
Container(
|
||||
width: 200,
|
||||
height: 200,
|
||||
child: FlameAnimationWidget(animation: _animation),
|
||||
child: AnimationWidget(animation: _animation),
|
||||
),
|
||||
const Text('Neat, hum?'),
|
||||
const Text(
|
||||
@ -99,7 +99,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
Container(
|
||||
width: 200,
|
||||
height: 200,
|
||||
child: FlameSpriteWidget(sprite: _sprite),
|
||||
child: SpriteWidget(sprite: _sprite),
|
||||
),
|
||||
const Text('Sprites from Elthen\'s amazing work on itch.io:'),
|
||||
const Text('https://elthen.itch.io/2d-pixel-art-minotaur-sprites'),
|
||||
|
||||
@ -6,8 +6,8 @@ import 'package:dashbook/dashbook.dart';
|
||||
|
||||
import 'package:flame/widgets/nine_tile_box.dart';
|
||||
import 'package:flame/widgets/sprite_button.dart';
|
||||
import 'package:flame/widgets/flame_sprite_widget.dart';
|
||||
import 'package:flame/widgets/flame_animation_widget.dart';
|
||||
import 'package:flame/widgets/sprite_widget.dart';
|
||||
import 'package:flame/widgets/animation_widget.dart';
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
@ -64,13 +64,13 @@ void main() async {
|
||||
);
|
||||
|
||||
final shieldSprite = await Sprite.loadSprite('shield.png');
|
||||
dashbook.storiesOf('FlameSpriteWidget').decorator(CenterDecorator()).add(
|
||||
dashbook.storiesOf('SpriteWidget').decorator(CenterDecorator()).add(
|
||||
'default',
|
||||
(ctx) => Container(
|
||||
width: ctx.numberProperty('container width', 400),
|
||||
height: ctx.numberProperty('container height', 200),
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: FlameSpriteWidget(
|
||||
child: SpriteWidget(
|
||||
sprite: shieldSprite,
|
||||
center: ctx.boolProperty('center', true),
|
||||
),
|
||||
@ -91,13 +91,13 @@ void main() async {
|
||||
to: 3,
|
||||
loop: true,
|
||||
);
|
||||
dashbook.storiesOf('FlameAnimationWidget').decorator(CenterDecorator()).add(
|
||||
dashbook.storiesOf('AnimationWidget').decorator(CenterDecorator()).add(
|
||||
'default',
|
||||
(ctx) => Container(
|
||||
width: ctx.numberProperty('container width', 400),
|
||||
height: ctx.numberProperty('container height', 200),
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: FlameAnimationWidget(
|
||||
child: AnimationWidget(
|
||||
animation: _animation,
|
||||
play: ctx.boolProperty('playing', true),
|
||||
center: ctx.boolProperty('center', true),
|
||||
|
||||
@ -48,28 +48,28 @@ SpriteButton(
|
||||
)
|
||||
```
|
||||
|
||||
## FlameSpriteWidget
|
||||
## SpriteWidget
|
||||
|
||||
`FlameSpriteWidget` is a widget used to display [Sprites](https://github.com/flame-engine/flame/blob/master/lib/sprite.dart) inside a widget tree.
|
||||
`SpriteWidget` is a widget used to display [Sprites](https://github.com/flame-engine/flame/blob/master/lib/sprite.dart) inside a widget tree.
|
||||
|
||||
How to use it:
|
||||
|
||||
```dart
|
||||
FlameSpriteWidget(
|
||||
SpriteWidget(
|
||||
sprite: shieldSprite,
|
||||
center: true,
|
||||
),
|
||||
|
||||
```
|
||||
|
||||
## FlameAnimationWidget
|
||||
## AnimationWidget
|
||||
|
||||
`FlameAnimationWidget` is a widget used to display [Animations](https://github.com/flame-engine/flame/blob/master/lib/animation.dart) inside a widget tree.
|
||||
`AnimationWidget` is a widget used to display [Animations](https://github.com/flame-engine/flame/blob/master/lib/animation.dart) inside a widget tree.
|
||||
|
||||
How to use it:
|
||||
|
||||
```dart
|
||||
FlameAnimationWidget(
|
||||
AnimationWidget(
|
||||
animation: _animation,
|
||||
play: true,
|
||||
center: true,
|
||||
|
||||
@ -155,7 +155,7 @@ class Util {
|
||||
/// You can use this implementation as base to easily create your own widgets based on more complex games.
|
||||
/// This is intended to be used by non-game apps that want to add a sprite sheet animation.
|
||||
///
|
||||
@Deprecated('Use FlameSpriteAnimation instead')
|
||||
@Deprecated('Use SpriteAnimation instead')
|
||||
widgets.Widget animationAsWidget(Position size, Animation animation) {
|
||||
return EmbeddedGameWidget(
|
||||
BaseGame()..add(AnimationComponent(size.x, size.y, animation)),
|
||||
@ -168,7 +168,7 @@ class Util {
|
||||
/// This will create a [CustomPaint] widget using a [CustomPainter] for rendering the [Sprite]
|
||||
/// Be aware that the Sprite must have been loaded, otherwise it can't be rendered
|
||||
///
|
||||
@Deprecated('Use FlameSpriteWidget instead')
|
||||
@Deprecated('Use SpriteWidget instead')
|
||||
widgets.CustomPaint spriteAsWidget(Size size, Sprite sprite) =>
|
||||
widgets.CustomPaint(size: size, painter: _SpriteCustomPainter(sprite));
|
||||
}
|
||||
|
||||
@ -1,26 +1,26 @@
|
||||
import 'package:flutter/material.dart' hide Animation;
|
||||
import 'package:flame/animation.dart';
|
||||
|
||||
import './flame_sprite_widget.dart';
|
||||
import './sprite_widget.dart';
|
||||
|
||||
import 'dart:math';
|
||||
|
||||
class FlameAnimationWidget extends StatefulWidget {
|
||||
class AnimationWidget extends StatefulWidget {
|
||||
final Animation animation;
|
||||
final bool center;
|
||||
final bool play;
|
||||
|
||||
FlameAnimationWidget({
|
||||
AnimationWidget({
|
||||
this.animation,
|
||||
this.play = true,
|
||||
this.center = false,
|
||||
}) : assert(animation.loaded(), 'Animation must be loaded');
|
||||
|
||||
@override
|
||||
State createState() => _FlameAnimationWidget();
|
||||
State createState() => _AnimationWidget();
|
||||
}
|
||||
|
||||
class _FlameAnimationWidget extends State<FlameAnimationWidget>
|
||||
class _AnimationWidget extends State<AnimationWidget>
|
||||
with SingleTickerProviderStateMixin {
|
||||
AnimationController _controller;
|
||||
double _lastUpdated;
|
||||
@ -82,7 +82,7 @@ class _FlameAnimationWidget extends State<FlameAnimationWidget>
|
||||
|
||||
@override
|
||||
Widget build(ctx) {
|
||||
return FlameSpriteWidget(
|
||||
return SpriteWidget(
|
||||
sprite: widget.animation.getSprite(), center: widget.center);
|
||||
}
|
||||
}
|
||||
@ -4,11 +4,11 @@ import '../sprite.dart';
|
||||
|
||||
import 'dart:math';
|
||||
|
||||
class FlameSpriteWidget extends StatelessWidget {
|
||||
class SpriteWidget extends StatelessWidget {
|
||||
final Sprite sprite;
|
||||
final bool center;
|
||||
|
||||
FlameSpriteWidget({
|
||||
SpriteWidget({
|
||||
@required this.sprite,
|
||||
this.center = false,
|
||||
}) : assert(sprite.loaded(), 'Sprite must be loaded');
|
||||
Reference in New Issue
Block a user