mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-01 10:38:17 +08:00
* 👌 Use `Offset` type directly in `JoystickAction.update` calculations (#631) * Move files to src and comply with the dart package layout convention * Fixing widgets example Co-authored-by: Serge Matveenko <lig@countzero.co> Co-authored-by: Erick Zanardo <erickzanardoo@gmail.com>
39 lines
666 B
Dart
39 lines
666 B
Dart
import 'dart:math';
|
|
|
|
import 'package:flame/components.dart';
|
|
import 'package:flame/effects.dart';
|
|
import 'package:flame/game.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flame/gestures.dart';
|
|
|
|
import './square.dart';
|
|
|
|
class MyGame extends BaseGame with TapDetector {
|
|
Square square;
|
|
|
|
MyGame() {
|
|
add(square = Square()
|
|
..anchor = Anchor.center
|
|
..x = 200
|
|
..y = 200);
|
|
}
|
|
|
|
@override
|
|
void onTap() {
|
|
square.addEffect(RotateEffect(
|
|
angle: 2 * pi,
|
|
isRelative: true,
|
|
duration: 5.0,
|
|
curve: Curves.bounceInOut,
|
|
));
|
|
}
|
|
}
|
|
|
|
void main() {
|
|
runApp(
|
|
GameWidget(
|
|
game: MyGame(),
|
|
),
|
|
);
|
|
}
|