mirror of
				https://github.com/flame-engine/flame.git
				synced 2025-10-31 17:06:50 +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>
		
			
				
	
	
		
			40 lines
		
	
	
		
			700 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
		
			700 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
| import 'package:flame/components.dart';
 | |
| import 'package:flame/effects.dart';
 | |
| import 'package:flutter/material.dart';
 | |
| import 'package:flame/game.dart';
 | |
| import 'package:flame/gestures.dart';
 | |
| 
 | |
| import './square.dart';
 | |
| 
 | |
| class MyGame extends BaseGame with TapDetector {
 | |
|   Square square;
 | |
|   bool grow = true;
 | |
| 
 | |
|   MyGame() {
 | |
|     add(square = Square()
 | |
|       ..anchor = Anchor.center
 | |
|       ..x = 200
 | |
|       ..y = 200);
 | |
|   }
 | |
| 
 | |
|   @override
 | |
|   void onTap() {
 | |
|     final s = grow ? 300.0 : 100.0;
 | |
| 
 | |
|     grow = !grow;
 | |
|     square.addEffect(ScaleEffect(
 | |
|       size: Vector2(s, s),
 | |
|       speed: 250.0,
 | |
|       curve: Curves.bounceInOut,
 | |
|     ));
 | |
|   }
 | |
| }
 | |
| 
 | |
| void main() {
 | |
|   runApp(
 | |
|     GameWidget(
 | |
|       game: MyGame(),
 | |
|     ),
 | |
|   );
 | |
| }
 |