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