Fixing release mode on examples that needed screenSize

This commit is contained in:
Erick Zanardo
2019-06-29 13:20:08 -03:00
parent ffe41c873b
commit 23fd8c8bc0
4 changed files with 38 additions and 34 deletions

View File

@ -4,22 +4,25 @@ import 'package:flame/animation.dart' as flame_animation;
import 'package:flame/components/animation_component.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyGame().widget);
void main() async{
final Size size = await Flame.util.initialDimensions();
runApp(MyGame(size).widget);
}
class MyGame extends BaseGame {
MyGame() {
Size screenSize;
MyGame(this.screenSize) {
_start();
}
void _start() async {
final Size size = await Flame.util.initialDimensions();
final animation = await flame_animation.Animation.fromAsepriteData(
'chopper.png', 'chopper.json');
final animationComponent = AnimationComponent(200, 200, animation);
animationComponent.x = (size.width / 2) - 100;
animationComponent.y = (size.height / 2) - 100;
animationComponent.x = (screenSize.width / 2) - 100;
animationComponent.y = (screenSize.height / 2) - 100;
add(animationComponent);
}