mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-20 15:08:36 +08:00
Renamed doc to docs and minor language fixes
This commit is contained in:
40
docs/examples/render_flip/lib/main.dart
Normal file
40
docs/examples/render_flip/lib/main.dart
Normal file
@@ -0,0 +1,40 @@
|
||||
import 'package:flame/flame.dart';
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:flame/animation.dart' as flame_animation;
|
||||
import 'package:flame/components/animation_component.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() async {
|
||||
final Size size = await Flame.util.initialDimensions();
|
||||
final game = MyGame(size);
|
||||
runApp(game.widget);
|
||||
}
|
||||
|
||||
class MyGame extends BaseGame {
|
||||
final animation = flame_animation.Animation.sequenced('chopper.png', 4,
|
||||
textureWidth: 48, textureHeight: 48, stepTime: 0.15);
|
||||
|
||||
AnimationComponent buildAnimation() {
|
||||
final ac = AnimationComponent(100, 100, animation);
|
||||
ac.x = size.width / 2 - ac.width / 2;
|
||||
return ac;
|
||||
}
|
||||
|
||||
MyGame(Size screenSize) {
|
||||
size = screenSize;
|
||||
|
||||
final regular = buildAnimation();
|
||||
regular.y = 100;
|
||||
add(regular);
|
||||
|
||||
final flipX = buildAnimation();
|
||||
flipX.y = 300;
|
||||
flipX.renderFlipX = true;
|
||||
add(flipX);
|
||||
|
||||
final flipY = buildAnimation();
|
||||
flipY.y = 500;
|
||||
flipY.renderFlipY = true;
|
||||
add(flipY);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user