From 34e7fb314eac0240ef6b51786ba6ed7a03e91330 Mon Sep 17 00:00:00 2001 From: Erick Zanardo Date: Tue, 2 Jul 2019 22:41:36 -0300 Subject: [PATCH] PR suggestions --- doc/examples/animations/lib/main.dart | 10 +++++----- doc/examples/aseprite/lib/main.dart | 9 ++++----- doc/examples/sound/lib/main.dart | 9 ++++----- doc/examples/text/lib/main.dart | 17 ++++++++--------- 4 files changed, 21 insertions(+), 24 deletions(-) diff --git a/doc/examples/animations/lib/main.dart b/doc/examples/animations/lib/main.dart index 3369b1eca..872a7b352 100644 --- a/doc/examples/animations/lib/main.dart +++ b/doc/examples/animations/lib/main.dart @@ -20,8 +20,6 @@ class MyGame extends BaseGame { final animation = flame_animation.Animation.sequenced('chopper.png', 4, textureWidth: 48, textureHeight: 48, stepTime: 0.15); - Size screenSize; - void addAnimation() { final animationComponent = AnimationComponent(100, 100, animation, destroyOnFinish: true); animationComponent.x = size.width / 2 - 50; @@ -30,14 +28,16 @@ class MyGame extends BaseGame { add(animationComponent); } - MyGame(this.screenSize) { + MyGame(Size screenSize) { + size = screenSize; + final animationComponent = AnimationComponent(100, 100, animation); - animationComponent.x = screenSize.width / 2 - 100; + animationComponent.x = size.width / 2 - 100; animationComponent.y = 100; final reversedAnimationComponent = AnimationComponent(100, 100, animation.reversed()); - reversedAnimationComponent.x = screenSize.width / 2; + reversedAnimationComponent.x = size.width / 2; reversedAnimationComponent.y = 100; add(animationComponent); diff --git a/doc/examples/aseprite/lib/main.dart b/doc/examples/aseprite/lib/main.dart index 10b0b6c53..7ab062746 100644 --- a/doc/examples/aseprite/lib/main.dart +++ b/doc/examples/aseprite/lib/main.dart @@ -10,9 +10,8 @@ void main() async{ } class MyGame extends BaseGame { - Size screenSize; - - MyGame(this.screenSize) { + MyGame(Size screenSize) { + size = screenSize; _start(); } @@ -21,8 +20,8 @@ class MyGame extends BaseGame { 'chopper.png', 'chopper.json'); final animationComponent = AnimationComponent(200, 200, animation); - animationComponent.x = (screenSize.width / 2) - 100; - animationComponent.y = (screenSize.height / 2) - 100; + animationComponent.x = (size.width / 2) - 100; + animationComponent.y = (size.height / 2) - 100; add(animationComponent); } diff --git a/doc/examples/sound/lib/main.dart b/doc/examples/sound/lib/main.dart index 0672c2fdc..ebc1bf97d 100644 --- a/doc/examples/sound/lib/main.dart +++ b/doc/examples/sound/lib/main.dart @@ -40,9 +40,8 @@ class Ball extends PositionComponent { } class MyGame extends BaseGame { - Size screenSize; - - MyGame(this.screenSize) { + MyGame(Size screenSize) { + size = screenSize; _start(); } @@ -52,8 +51,8 @@ class MyGame extends BaseGame { Flame.audio.load('boin.mp3'); Flame.audio.loop('music.mp3', volume: 0.4); - add(Ball(this.screenSize) - ..y = (this.screenSize.height / 2) - 50 + add(Ball(size) + ..y = (size.height / 2) - 50 ..width = 100 ..height = 100); } diff --git a/doc/examples/text/lib/main.dart b/doc/examples/text/lib/main.dart index bc3092b33..c10090dee 100644 --- a/doc/examples/text/lib/main.dart +++ b/doc/examples/text/lib/main.dart @@ -35,27 +35,26 @@ class MyTextBox extends TextBoxComponent { } class MyGame extends BaseGame { - Size screenSize; - - MyGame(this.screenSize) { + MyGame(Size screenSize) { + size = screenSize; add(TextComponent('Hello, Flame', config: regular) ..anchor = Anchor.topCenter - ..x = screenSize.width / 2 + ..x = size.width / 2 ..y = 32.0); add(TextComponent('center', config: tiny) ..anchor = Anchor.center - ..x = screenSize.width / 2 - ..y = screenSize.height / 2); + ..x = size.width / 2 + ..y = size.height / 2); add(TextComponent('bottomRight', config: tiny) ..anchor = Anchor.bottomRight - ..x = screenSize.width - ..y = screenSize.height); + ..x = size.width + ..y = size.height); add(MyTextBox( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam eget ligula eu lectus lobortis condimentum.') ..anchor = Anchor.bottomLeft - ..y = screenSize.height); + ..y = size.height); } }