mirror of
				https://github.com/flame-engine/flame.git
				synced 2025-11-01 01:18:38 +08:00 
			
		
		
		
	 fabbf928d0
			
		
	
	fabbf928d0
	
	
	
		
			
			Enable DCM rule double-literal-format. More details [here](https://dcm.dev/docs/rules/common/double-literal-format/). This both forbids trailing zeroes and mandates leading zeroes. If we would prefer a different style (e.g. prefer no leading zero instead), just lmk :)
		
			
				
	
	
		
			43 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
| import 'dart:async';
 | |
| 
 | |
| import 'package:flame/components.dart';
 | |
| import 'package:flame/events.dart';
 | |
| import 'package:flame/extensions.dart';
 | |
| import 'package:flame/game.dart';
 | |
| import 'package:flame/input.dart';
 | |
| import 'package:flame_network_assets/flame_network_assets.dart';
 | |
| import 'package:flutter/material.dart' hide Image;
 | |
| 
 | |
| void main() {
 | |
|   runApp(const GameWidget.controlled(gameFactory: MyGame.new));
 | |
| }
 | |
| 
 | |
| class MyGame extends FlameGame with TapDetector {
 | |
|   final networkImages = FlameNetworkImages();
 | |
|   late Image playerSprite;
 | |
| 
 | |
|   @override
 | |
|   Future<void> onLoad() async {
 | |
|     playerSprite = await networkImages.load(
 | |
|       'https://examples.flame-engine.org/assets/assets/images/bomb_ptero.png',
 | |
|     );
 | |
|   }
 | |
| 
 | |
|   @override
 | |
|   void onTapUp(TapUpInfo info) {
 | |
|     add(
 | |
|       SpriteAnimationComponent.fromFrameData(
 | |
|         playerSprite,
 | |
|         SpriteAnimationData.sequenced(
 | |
|           textureSize: Vector2(48, 32),
 | |
|           amount: 4,
 | |
|           stepTime: 0.2,
 | |
|         ),
 | |
|         size: Vector2(100, 50),
 | |
|         anchor: Anchor.center,
 | |
|         position: info.eventPosition.widget,
 | |
|       ),
 | |
|     );
 | |
|   }
 | |
| }
 |