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,
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);

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}
}