PR suggestions

This commit is contained in:
Erick Zanardo
2019-07-02 22:41:36 -03:00
parent cb42631dab
commit 34e7fb314e
4 changed files with 21 additions and 24 deletions

View File

@ -20,8 +20,6 @@ class MyGame extends BaseGame {
final animation = flame_animation.Animation.sequenced('chopper.png', 4, final animation = flame_animation.Animation.sequenced('chopper.png', 4,
textureWidth: 48, textureHeight: 48, stepTime: 0.15); textureWidth: 48, textureHeight: 48, stepTime: 0.15);
Size screenSize;
void addAnimation() { void addAnimation() {
final animationComponent = AnimationComponent(100, 100, animation, destroyOnFinish: true); final animationComponent = AnimationComponent(100, 100, animation, destroyOnFinish: true);
animationComponent.x = size.width / 2 - 50; animationComponent.x = size.width / 2 - 50;
@ -30,14 +28,16 @@ class MyGame extends BaseGame {
add(animationComponent); add(animationComponent);
} }
MyGame(this.screenSize) { MyGame(Size screenSize) {
size = screenSize;
final animationComponent = AnimationComponent(100, 100, animation); final animationComponent = AnimationComponent(100, 100, animation);
animationComponent.x = screenSize.width / 2 - 100; animationComponent.x = size.width / 2 - 100;
animationComponent.y = 100; animationComponent.y = 100;
final reversedAnimationComponent = final reversedAnimationComponent =
AnimationComponent(100, 100, animation.reversed()); AnimationComponent(100, 100, animation.reversed());
reversedAnimationComponent.x = screenSize.width / 2; reversedAnimationComponent.x = size.width / 2;
reversedAnimationComponent.y = 100; reversedAnimationComponent.y = 100;
add(animationComponent); add(animationComponent);

View File

@ -10,9 +10,8 @@ void main() async{
} }
class MyGame extends BaseGame { class MyGame extends BaseGame {
Size screenSize; MyGame(Size screenSize) {
size = screenSize;
MyGame(this.screenSize) {
_start(); _start();
} }
@ -21,8 +20,8 @@ class MyGame extends BaseGame {
'chopper.png', 'chopper.json'); 'chopper.png', 'chopper.json');
final animationComponent = AnimationComponent(200, 200, animation); final animationComponent = AnimationComponent(200, 200, animation);
animationComponent.x = (screenSize.width / 2) - 100; animationComponent.x = (size.width / 2) - 100;
animationComponent.y = (screenSize.height / 2) - 100; animationComponent.y = (size.height / 2) - 100;
add(animationComponent); add(animationComponent);
} }

View File

@ -40,9 +40,8 @@ class Ball extends PositionComponent {
} }
class MyGame extends BaseGame { class MyGame extends BaseGame {
Size screenSize; MyGame(Size screenSize) {
size = screenSize;
MyGame(this.screenSize) {
_start(); _start();
} }
@ -52,8 +51,8 @@ class MyGame extends BaseGame {
Flame.audio.load('boin.mp3'); Flame.audio.load('boin.mp3');
Flame.audio.loop('music.mp3', volume: 0.4); Flame.audio.loop('music.mp3', volume: 0.4);
add(Ball(this.screenSize) add(Ball(size)
..y = (this.screenSize.height / 2) - 50 ..y = (size.height / 2) - 50
..width = 100 ..width = 100
..height = 100); ..height = 100);
} }

View File

@ -35,27 +35,26 @@ class MyTextBox extends TextBoxComponent {
} }
class MyGame extends BaseGame { class MyGame extends BaseGame {
Size screenSize; MyGame(Size screenSize) {
size = screenSize;
MyGame(this.screenSize) {
add(TextComponent('Hello, Flame', config: regular) add(TextComponent('Hello, Flame', config: regular)
..anchor = Anchor.topCenter ..anchor = Anchor.topCenter
..x = screenSize.width / 2 ..x = size.width / 2
..y = 32.0); ..y = 32.0);
add(TextComponent('center', config: tiny) add(TextComponent('center', config: tiny)
..anchor = Anchor.center ..anchor = Anchor.center
..x = screenSize.width / 2 ..x = size.width / 2
..y = screenSize.height / 2); ..y = size.height / 2);
add(TextComponent('bottomRight', config: tiny) add(TextComponent('bottomRight', config: tiny)
..anchor = Anchor.bottomRight ..anchor = Anchor.bottomRight
..x = screenSize.width ..x = size.width
..y = screenSize.height); ..y = size.height);
add(MyTextBox( add(MyTextBox(
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam eget ligula eu lectus lobortis condimentum.') 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam eget ligula eu lectus lobortis condimentum.')
..anchor = Anchor.bottomLeft ..anchor = Anchor.bottomLeft
..y = screenSize.height); ..y = size.height);
} }
} }