mirror of
				https://github.com/flame-engine/flame.git
				synced 2025-11-01 01:18:38 +08:00 
			
		
		
		
	 463c6e651e
			
		
	
	463c6e651e
	
	
	
		
			
			* Move flame_svg to monorepo * Add code metrics * Remove comment from example pubspec * Correct asset_cache import
		
			
				
	
	
		
			34 lines
		
	
	
		
			655 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			655 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
| import 'package:flame/game.dart';
 | |
| import 'package:flame_svg/flame_svg.dart';
 | |
| 
 | |
| import 'package:flutter/material.dart';
 | |
| 
 | |
| void main() {
 | |
|   runApp(GameWidget(game: MyGame()));
 | |
| }
 | |
| 
 | |
| class MyGame extends BaseGame {
 | |
|   late Svg svgInstance;
 | |
| 
 | |
|   @override
 | |
|   void render(Canvas canvas) {
 | |
|     super.render(canvas);
 | |
|     svgInstance.renderPosition(
 | |
|       canvas,
 | |
|       Vector2(100, 200),
 | |
|       Vector2.all(300),
 | |
|     );
 | |
|   }
 | |
| 
 | |
|   @override
 | |
|   Future<void> onLoad() async {
 | |
|     svgInstance = await loadSvg('android.svg');
 | |
|     final android = SvgComponent.fromSvg(
 | |
|       svgInstance,
 | |
|       position: Vector2.all(100),
 | |
|       size: Vector2.all(100),
 | |
|     );
 | |
|     add(android);
 | |
|   }
 | |
| }
 |