mirror of
				https://github.com/flame-engine/flame.git
				synced 2025-11-01 01:18:38 +08:00 
			
		
		
		
	 ccee9a466b
			
		
	
	ccee9a466b
	
	
	
		
			
			* 👌 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>
		
			
				
	
	
		
			46 lines
		
	
	
		
			903 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			903 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
| import 'package:flame/effects.dart';
 | |
| import 'package:flame/game.dart';
 | |
| import 'package:flame/gestures.dart';
 | |
| import 'package:flame/extensions.dart';
 | |
| import 'package:flutter/animation.dart';
 | |
| import 'package:flutter/widgets.dart';
 | |
| 
 | |
| import './square.dart';
 | |
| 
 | |
| class MyGame extends BaseGame with TapDetector {
 | |
|   Square square;
 | |
| 
 | |
|   MyGame() {
 | |
|     add(square = Square()
 | |
|       ..x = 100
 | |
|       ..y = 100);
 | |
|   }
 | |
| 
 | |
|   @override
 | |
|   void onTapUp(TapUpDetails details) {
 | |
|     square.addEffect(MoveEffect(
 | |
|       path: [
 | |
|         details.localPosition.toVector2(),
 | |
|         Vector2(100, 100),
 | |
|         Vector2(50, 120),
 | |
|         Vector2(200, 400),
 | |
|         Vector2(150, 0),
 | |
|         Vector2(100, 300),
 | |
|       ],
 | |
|       speed: 250.0,
 | |
|       curve: Curves.bounceInOut,
 | |
|       isRelative: false,
 | |
|       isInfinite: false,
 | |
|       isAlternating: true,
 | |
|     ));
 | |
|   }
 | |
| }
 | |
| 
 | |
| void main() {
 | |
|   runApp(
 | |
|     GameWidget(
 | |
|       game: MyGame(),
 | |
|     ),
 | |
|   );
 | |
| }
 |