This commit is contained in:
Erick Zanardo
2020-05-30 15:24:52 -03:00
parent 11375751d0
commit 375df766b1
3 changed files with 14 additions and 12 deletions

View File

@ -118,7 +118,8 @@ class Util {
/// Read more at: https://flame-engine.org/docs/input.md
///
@Deprecated(
'This method can lead to confuse behaviour, use the gestures methods provided by the Game class')
'This method can lead to confuse behaviour, use the gestures methods provided by the Game class',
)
void addGestureRecognizer(GestureRecognizer recognizer) {
if (GestureBinding.instance == null) {
throw Exception(

View File

@ -1,11 +1,11 @@
import 'package:flutter/material.dart' hide Animation;
import 'package:flame/animation.dart';
import 'dart:math';
import '../anchor.dart';
import './sprite_widget.dart';
import 'dart:math';
class AnimationWidget extends StatefulWidget {
final Animation animation;
final Anchor anchor;
@ -64,15 +64,13 @@ class _AnimationWidget extends State<AnimationWidget>
widget.animation.reset();
_lastUpdated = DateTime.now().millisecond.toDouble();
_controller.repeat(
// -/+ 60 fps
// Approximately 60 fps
period: const Duration(milliseconds: 16));
});
}
void _pauseAnimation() {
setState(() {
_controller.stop();
});
setState(() => _controller.stop());
}
@override
@ -84,6 +82,8 @@ class _AnimationWidget extends State<AnimationWidget>
@override
Widget build(ctx) {
return SpriteWidget(
sprite: widget.animation.getSprite(), anchor: widget.anchor);
sprite: widget.animation.getSprite(),
anchor: widget.anchor,
);
}
}

View File

@ -1,10 +1,10 @@
import 'package:flutter/widgets.dart';
import 'package:meta/meta.dart';
import 'dart:math';
import '../sprite.dart';
import '../anchor.dart';
import 'dart:math';
class SpriteWidget extends StatelessWidget {
final Sprite sprite;
final Anchor anchor;
@ -29,8 +29,9 @@ class _SpritePainer extends CustomPainter {
_SpritePainer(this._sprite, this._anchor);
@override
bool shouldRepaint(_SpritePainer old) =>
old._sprite != _sprite || old._anchor != _anchor;
bool shouldRepaint(_SpritePainer old) {
return old._sprite != _sprite || old._anchor != _anchor;
}
@override
void paint(Canvas canvas, Size size) {