mirror of
				https://github.com/flame-engine/flame.git
				synced 2025-10-31 08:56:01 +08:00 
			
		
		
		
	 8b132d7c0b
			
		
	
	8b132d7c0b
	
	
	
		
			
			* Animations, CameraAndViewport, CollisionDetection and Components unified * Added descriptions to effects * Rename input games * Unify input stories * Add info to parallax section * Added descriptions to the rendering examples * Add descriptions to the sprites directory * Fix utils and rendering section * Add descriptions to the widgets section * Delete directory that rebase brought back * Unify game names * Added some styleguide docs for examples * Fix analyze issues * All files should have _example as suffix * Made the FollowComponentExample a bit easier to understand * Change priority of ember
		
			
				
	
	
		
			40 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
| import 'package:flame/components.dart';
 | |
| import 'package:flame/game.dart';
 | |
| import 'package:flame/input.dart';
 | |
| import 'package:flutter/material.dart';
 | |
| 
 | |
| class NineTileBoxExample extends FlameGame with TapDetector, DoubleTapDetector {
 | |
|   static const String description = '''
 | |
|     If you want to create a background for something that can stretch you can
 | |
|     use the `NineTileBox` which is showcased here.\n\n
 | |
|     Tap to make the box bigger and double tap to make it smaller.
 | |
|   ''';
 | |
| 
 | |
|   late NineTileBox nineTileBox;
 | |
|   final Vector2 boxSize = Vector2.all(300);
 | |
| 
 | |
|   @override
 | |
|   Future<void> onLoad() async {
 | |
|     await super.onLoad();
 | |
|     final sprite = Sprite(await images.load('nine-box.png'));
 | |
|     nineTileBox = NineTileBox(sprite, tileSize: 8, destTileSize: 24);
 | |
|   }
 | |
| 
 | |
|   @override
 | |
|   void render(Canvas canvas) {
 | |
|     super.render(canvas);
 | |
|     final position = (size - boxSize) / 2;
 | |
|     nineTileBox.draw(canvas, position, boxSize);
 | |
|   }
 | |
| 
 | |
|   @override
 | |
|   void onTap() {
 | |
|     boxSize.scale(1.2);
 | |
|   }
 | |
| 
 | |
|   @override
 | |
|   void onDoubleTap() {
 | |
|     boxSize.scale(0.8);
 | |
|   }
 | |
| }
 |