mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-01 10:38:17 +08:00
Fixing release mode on examples that needed screenSize
This commit is contained in:
@ -5,9 +5,11 @@ import 'package:flame/animation.dart' as flame_animation;
|
||||
import 'package:flame/components/animation_component.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() {
|
||||
final game = MyGame();
|
||||
void main() async {
|
||||
final Size size = await Flame.util.initialDimensions();
|
||||
final game = MyGame(size);
|
||||
runApp(game.widget);
|
||||
|
||||
Flame.util.addGestureRecognizer(TapGestureRecognizer()
|
||||
..onTapDown = (TapDownDetails evt) {
|
||||
game.addAnimation();
|
||||
@ -18,9 +20,7 @@ class MyGame extends BaseGame {
|
||||
final animation = flame_animation.Animation.sequenced('chopper.png', 4,
|
||||
textureWidth: 48, textureHeight: 48, stepTime: 0.15);
|
||||
|
||||
MyGame() {
|
||||
_start();
|
||||
}
|
||||
Size screenSize;
|
||||
|
||||
void addAnimation() {
|
||||
final animationComponent = AnimationComponent(100, 100, animation, destroyOnFinish: true);
|
||||
@ -30,16 +30,14 @@ class MyGame extends BaseGame {
|
||||
add(animationComponent);
|
||||
}
|
||||
|
||||
void _start() async {
|
||||
final Size size = await Flame.util.initialDimensions();
|
||||
|
||||
MyGame(this.screenSize) {
|
||||
final animationComponent = AnimationComponent(100, 100, animation);
|
||||
animationComponent.x = size.width / 2 - 100;
|
||||
animationComponent.x = screenSize.width / 2 - 100;
|
||||
animationComponent.y = 100;
|
||||
|
||||
final reversedAnimationComponent =
|
||||
AnimationComponent(100, 100, animation.reversed());
|
||||
reversedAnimationComponent.x = size.width / 2;
|
||||
reversedAnimationComponent.x = screenSize.width / 2;
|
||||
reversedAnimationComponent.y = 100;
|
||||
|
||||
add(animationComponent);
|
||||
|
||||
Reference in New Issue
Block a user