flutter formar

This commit is contained in:
Renan Araujo
2019-03-22 13:37:42 -03:00
parent b1a3d222a9
commit aacb3fcb65
8 changed files with 27 additions and 25 deletions

View File

@ -14,13 +14,15 @@ class MyGame extends BaseGame {
_start() async {
Size size = await Flame.util.initialDimensions();
final animation = await FlameAnimation.Animation.sequenced('chopper.png', 4, textureWidth: 48, textureHeight: 48, stepTime: 0.15);
final animation = await FlameAnimation.Animation.sequenced('chopper.png', 4,
textureWidth: 48, textureHeight: 48, stepTime: 0.15);
final animationComponent = AnimationComponent(100, 100, animation);
animationComponent.x = size.width / 2 - 100;
animationComponent.y = 100;
final reversedAnimationComponent = AnimationComponent(100, 100, animation.reversed());
final reversedAnimationComponent =
AnimationComponent(100, 100, animation.reversed());
reversedAnimationComponent.x = size.width / 2;
reversedAnimationComponent.y = 100;
@ -28,4 +30,3 @@ class MyGame extends BaseGame {
add(reversedAnimationComponent);
}
}

View File

@ -8,7 +8,6 @@ import 'package:flutter/material.dart';
void main() => runApp(MyGame());
class MyGame extends BaseGame {
Svg svgInstance;
SvgComponent android;
@ -31,5 +30,4 @@ class MyGame extends BaseGame {
svgInstance.renderPosition(canvas, Position(100, 200), 300, 300);
}
}

View File

@ -41,7 +41,8 @@ class Animation {
///
/// All frames have the same [stepTime].
Animation.spriteList(List<Sprite> sprites, {double stepTime, this.loop = true}) {
Animation.spriteList(List<Sprite> sprites,
{double stepTime, this.loop = true}) {
frames = sprites.map((s) => Frame(s, stepTime)).toList();
}

View File

@ -157,7 +157,8 @@ class TextBoxComponent extends PositionComponent with Resizable {
.paint(c, Offset(_boxConfig.margin, dy));
dy += _lineHeight;
}
final int max = math.min(currentChar - charCount, _lines[_currentLine].length);
final int max =
math.min(currentChar - charCount, _lines[_currentLine].length);
_config
.toTextPainter(_lines[_currentLine].substring(0, max))
.paint(c, Offset(_boxConfig.margin, dy));

View File

@ -29,7 +29,8 @@ class Svg {
/// Renders the svg on the [canvas] on the given [position] using the dimmensions provided on [width] and [height]
///
/// If not loaded, does nothing
void renderPosition(Canvas canvas, Position position, double width, double height) {
void renderPosition(
Canvas canvas, Position position, double width, double height) {
if (!loaded()) {
return;
}