mirror of
https://github.com/flame-engine/flame.git
synced 2025-10-30 16:36:57 +08:00
Linting
This commit is contained in:
@ -7,7 +7,7 @@ import 'package:flame/game.dart';
|
||||
import 'package:flame/palette.dart';
|
||||
import 'package:flame/position.dart';
|
||||
import 'package:flame/text_config.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flame/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() async {
|
||||
@ -15,16 +15,12 @@ void main() async {
|
||||
final Size size = await Flame.util.initialDimensions();
|
||||
final MyGame game = MyGame(size);
|
||||
runApp(game.widget);
|
||||
|
||||
final TapGestureRecognizer taps = TapGestureRecognizer()
|
||||
..onTapDown = (_) => game.tap();
|
||||
Flame.util.addGestureRecognizer(taps);
|
||||
}
|
||||
|
||||
TextConfig regular = TextConfig(color: BasicPalette.white.color);
|
||||
AudioPool pool = AudioPool('laser.mp3');
|
||||
|
||||
class MyGame extends BaseGame {
|
||||
class MyGame extends BaseGame with TapDetector {
|
||||
MyGame(Size screenSize) {
|
||||
size = screenSize;
|
||||
}
|
||||
@ -38,7 +34,8 @@ class MyGame extends BaseGame {
|
||||
super.render(canvas);
|
||||
}
|
||||
|
||||
void tap() {
|
||||
@override
|
||||
void onTap() {
|
||||
pool.start();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import 'dart:ui';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flame/flame.dart';
|
||||
import 'package:flame/gestures.dart';
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:flame/flare_animation.dart';
|
||||
import 'package:flame/components/flare_component.dart';
|
||||
@ -14,14 +13,9 @@ void main() {
|
||||
|
||||
final game = MyGame();
|
||||
runApp(game.widget);
|
||||
|
||||
Flame.util.addGestureRecognizer(TapGestureRecognizer()
|
||||
..onTapDown = (TapDownDetails evt) {
|
||||
game.cycleAnimation();
|
||||
});
|
||||
}
|
||||
|
||||
class MyGame extends BaseGame {
|
||||
class MyGame extends BaseGame with TapDetector {
|
||||
final TextConfig fpsTextConfig =
|
||||
const TextConfig(color: const Color(0xFFFFFFFF));
|
||||
|
||||
@ -39,6 +33,11 @@ class MyGame extends BaseGame {
|
||||
@override
|
||||
bool debugMode() => true;
|
||||
|
||||
@override
|
||||
void onTap() {
|
||||
cycleAnimation();
|
||||
}
|
||||
|
||||
void cycleAnimation() {
|
||||
if (_currentAnimation == 3) {
|
||||
_currentAnimation = 0;
|
||||
|
||||
Reference in New Issue
Block a user