mirror of
				https://github.com/flame-engine/flame.git
				synced 2025-11-04 04:47:13 +08:00 
			
		
		
		
	pr nits
This commit is contained in:
		@ -118,7 +118,8 @@ class Util {
 | 
				
			|||||||
  /// Read more at: https://flame-engine.org/docs/input.md
 | 
					  /// Read more at: https://flame-engine.org/docs/input.md
 | 
				
			||||||
  ///
 | 
					  ///
 | 
				
			||||||
  @Deprecated(
 | 
					  @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) {
 | 
					  void addGestureRecognizer(GestureRecognizer recognizer) {
 | 
				
			||||||
    if (GestureBinding.instance == null) {
 | 
					    if (GestureBinding.instance == null) {
 | 
				
			||||||
      throw Exception(
 | 
					      throw Exception(
 | 
				
			||||||
 | 
				
			|||||||
@ -1,11 +1,11 @@
 | 
				
			|||||||
import 'package:flutter/material.dart' hide Animation;
 | 
					import 'package:flutter/material.dart' hide Animation;
 | 
				
			||||||
import 'package:flame/animation.dart';
 | 
					import 'package:flame/animation.dart';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import 'dart:math';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import '../anchor.dart';
 | 
					import '../anchor.dart';
 | 
				
			||||||
import './sprite_widget.dart';
 | 
					import './sprite_widget.dart';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import 'dart:math';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class AnimationWidget extends StatefulWidget {
 | 
					class AnimationWidget extends StatefulWidget {
 | 
				
			||||||
  final Animation animation;
 | 
					  final Animation animation;
 | 
				
			||||||
  final Anchor anchor;
 | 
					  final Anchor anchor;
 | 
				
			||||||
@ -64,15 +64,13 @@ class _AnimationWidget extends State<AnimationWidget>
 | 
				
			|||||||
      widget.animation.reset();
 | 
					      widget.animation.reset();
 | 
				
			||||||
      _lastUpdated = DateTime.now().millisecond.toDouble();
 | 
					      _lastUpdated = DateTime.now().millisecond.toDouble();
 | 
				
			||||||
      _controller.repeat(
 | 
					      _controller.repeat(
 | 
				
			||||||
          // -/+ 60 fps
 | 
					          // Approximately 60 fps
 | 
				
			||||||
          period: const Duration(milliseconds: 16));
 | 
					          period: const Duration(milliseconds: 16));
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void _pauseAnimation() {
 | 
					  void _pauseAnimation() {
 | 
				
			||||||
    setState(() {
 | 
					    setState(() => _controller.stop());
 | 
				
			||||||
      _controller.stop();
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @override
 | 
					  @override
 | 
				
			||||||
@ -84,6 +82,8 @@ class _AnimationWidget extends State<AnimationWidget>
 | 
				
			|||||||
  @override
 | 
					  @override
 | 
				
			||||||
  Widget build(ctx) {
 | 
					  Widget build(ctx) {
 | 
				
			||||||
    return SpriteWidget(
 | 
					    return SpriteWidget(
 | 
				
			||||||
        sprite: widget.animation.getSprite(), anchor: widget.anchor);
 | 
					      sprite: widget.animation.getSprite(),
 | 
				
			||||||
 | 
					      anchor: widget.anchor,
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -1,10 +1,10 @@
 | 
				
			|||||||
import 'package:flutter/widgets.dart';
 | 
					import 'package:flutter/widgets.dart';
 | 
				
			||||||
import 'package:meta/meta.dart';
 | 
					import 'package:meta/meta.dart';
 | 
				
			||||||
 | 
					import 'dart:math';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import '../sprite.dart';
 | 
					import '../sprite.dart';
 | 
				
			||||||
import '../anchor.dart';
 | 
					import '../anchor.dart';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import 'dart:math';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class SpriteWidget extends StatelessWidget {
 | 
					class SpriteWidget extends StatelessWidget {
 | 
				
			||||||
  final Sprite sprite;
 | 
					  final Sprite sprite;
 | 
				
			||||||
  final Anchor anchor;
 | 
					  final Anchor anchor;
 | 
				
			||||||
@ -29,8 +29,9 @@ class _SpritePainer extends CustomPainter {
 | 
				
			|||||||
  _SpritePainer(this._sprite, this._anchor);
 | 
					  _SpritePainer(this._sprite, this._anchor);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @override
 | 
					  @override
 | 
				
			||||||
  bool shouldRepaint(_SpritePainer old) =>
 | 
					  bool shouldRepaint(_SpritePainer old) {
 | 
				
			||||||
      old._sprite != _sprite || old._anchor != _anchor;
 | 
					    return old._sprite != _sprite || old._anchor != _anchor;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @override
 | 
					  @override
 | 
				
			||||||
  void paint(Canvas canvas, Size size) {
 | 
					  void paint(Canvas canvas, Size size) {
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user