mirror of
				https://github.com/flame-engine/flame.git
				synced 2025-11-01 01:18:38 +08:00 
			
		
		
		
	Adding basic SVG support (#61)
This commit is contained in:
		
							
								
								
									
										35
									
								
								doc/examples/svg/lib/main.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								doc/examples/svg/lib/main.dart
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,35 @@ | ||||
| import 'package:flame/game.dart'; | ||||
| import 'package:flame/svg.dart'; | ||||
| import 'package:flame/position.dart'; | ||||
| import 'package:flame/components/component.dart' show SvgComponent; | ||||
|  | ||||
| import 'package:flutter/material.dart'; | ||||
|  | ||||
| void main() => runApp(MyGame()); | ||||
|  | ||||
| class MyGame extends BaseGame { | ||||
|  | ||||
|   Svg svgInstance; | ||||
|   SvgComponent android; | ||||
|  | ||||
|   MyGame() { | ||||
|     _start(); | ||||
|   } | ||||
|  | ||||
|   _start() async { | ||||
|     svgInstance = Svg('android.svg'); | ||||
|     android = SvgComponent.fromSvg(100, 100, svgInstance); | ||||
|     android.x = 100; | ||||
|     android.y = 100; | ||||
|  | ||||
|     add(android); | ||||
|   } | ||||
|  | ||||
|   @override | ||||
|   void render(Canvas canvas) { | ||||
|     super.render(canvas); | ||||
|  | ||||
|     svgInstance.renderPosition(canvas, Position(100, 200), 300, 300); | ||||
|   } | ||||
|  | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 Erick
					Erick