mirror of
				https://github.com/flame-engine/flame.git
				synced 2025-11-01 01:18:38 +08:00 
			
		
		
		
	docs: Fix naming of drag- and tap-callbacks examples (#2873)
Fix naming of drag- and tap-callbacks examples
This commit is contained in:
		| @ -3,14 +3,14 @@ import 'package:flame/events.dart'; | |||||||
| import 'package:flame/game.dart'; | import 'package:flame/game.dart'; | ||||||
| import 'package:flutter/material.dart' show Colors; | import 'package:flutter/material.dart' show Colors; | ||||||
| 
 | 
 | ||||||
| class DraggablesExample extends FlameGame { | class DragCallbacksExample extends FlameGame { | ||||||
|   static const String description = ''' |   static const String description = ''' | ||||||
|     In this example we show you can use the `DragCallbacks` mixin on |     In this example we show you can use the `DragCallbacks` mixin on | ||||||
|     `PositionComponent`s. Drag around the Embers and see their position |     `PositionComponent`s. Drag around the Embers and see their position | ||||||
|     changing. |     changing. | ||||||
|   '''; |   '''; | ||||||
| 
 | 
 | ||||||
|   DraggablesExample({required this.zoom}); |   DragCallbacksExample({required this.zoom}); | ||||||
| 
 | 
 | ||||||
|   final double zoom; |   final double zoom; | ||||||
|   late final DraggableEmber square; |   late final DraggableEmber square; | ||||||
| @ -34,19 +34,12 @@ class DraggableEmber extends Ember with DragCallbacks { | |||||||
|   @override |   @override | ||||||
|   void update(double dt) { |   void update(double dt) { | ||||||
|     super.update(dt); |     super.update(dt); | ||||||
|     debugColor = isDragged && findGame() is DraggablesExample |     debugColor = isDragged ? Colors.greenAccent : Colors.purple; | ||||||
|         ? Colors.greenAccent |  | ||||||
|         : Colors.purple; |  | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   @override |   @override | ||||||
|   void onDragUpdate(DragUpdateEvent event) { |   void onDragUpdate(DragUpdateEvent event) { | ||||||
|     if (findGame() is! DraggablesExample) { |     event.continuePropagation = true; | ||||||
|       event.continuePropagation = true; |     return; | ||||||
|       return; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     position.add(event.delta); |  | ||||||
|     event.continuePropagation = false; |  | ||||||
|   } |   } | ||||||
| } | } | ||||||
| @ -2,7 +2,7 @@ import 'package:dashbook/dashbook.dart'; | |||||||
| import 'package:examples/commons/commons.dart'; | import 'package:examples/commons/commons.dart'; | ||||||
| import 'package:examples/stories/input/advanced_button_example.dart'; | import 'package:examples/stories/input/advanced_button_example.dart'; | ||||||
| import 'package:examples/stories/input/double_tap_callbacks_example.dart'; | import 'package:examples/stories/input/double_tap_callbacks_example.dart'; | ||||||
| import 'package:examples/stories/input/draggables_example.dart'; | import 'package:examples/stories/input/drag_callbacks_example.dart'; | ||||||
| import 'package:examples/stories/input/gesture_hitboxes_example.dart'; | import 'package:examples/stories/input/gesture_hitboxes_example.dart'; | ||||||
| import 'package:examples/stories/input/hardware_keyboard_example.dart'; | import 'package:examples/stories/input/hardware_keyboard_example.dart'; | ||||||
| import 'package:examples/stories/input/hover_callbacks_example.dart'; | import 'package:examples/stories/input/hover_callbacks_example.dart'; | ||||||
| @ -14,7 +14,7 @@ import 'package:examples/stories/input/mouse_cursor_example.dart'; | |||||||
| import 'package:examples/stories/input/mouse_movement_example.dart'; | import 'package:examples/stories/input/mouse_movement_example.dart'; | ||||||
| import 'package:examples/stories/input/multitap_advanced_example.dart'; | import 'package:examples/stories/input/multitap_advanced_example.dart'; | ||||||
| import 'package:examples/stories/input/multitap_example.dart'; | import 'package:examples/stories/input/multitap_example.dart'; | ||||||
| import 'package:examples/stories/input/overlapping_tappables_example.dart'; | import 'package:examples/stories/input/overlapping_tap_callbacks_example.dart'; | ||||||
| import 'package:examples/stories/input/scroll_example.dart'; | import 'package:examples/stories/input/scroll_example.dart'; | ||||||
| import 'package:examples/stories/input/tap_callbacks_example.dart'; | import 'package:examples/stories/input/tap_callbacks_example.dart'; | ||||||
| import 'package:flame/game.dart'; | import 'package:flame/game.dart'; | ||||||
| @ -29,16 +29,16 @@ void addInputStories(Dashbook dashbook) { | |||||||
|       info: TapCallbacksExample.description, |       info: TapCallbacksExample.description, | ||||||
|     ) |     ) | ||||||
|     ..add( |     ..add( | ||||||
|       'Draggables', |       'DragCallbacks', | ||||||
|       (context) { |       (context) { | ||||||
|         return GameWidget( |         return GameWidget( | ||||||
|           game: DraggablesExample( |           game: DragCallbacksExample( | ||||||
|             zoom: context.listProperty('zoom', 1, [0.5, 1, 1.5]), |             zoom: context.listProperty('zoom', 1, [0.5, 1, 1.5]), | ||||||
|           ), |           ), | ||||||
|         ); |         ); | ||||||
|       }, |       }, | ||||||
|       codeLink: baseLink('input/draggables_example.dart'), |       codeLink: baseLink('input/drag_callbacks_example.dart'), | ||||||
|       info: DraggablesExample.description, |       info: DragCallbacksExample.description, | ||||||
|     ) |     ) | ||||||
|     ..add( |     ..add( | ||||||
|       'Double Tap (Component)', |       'Double Tap (Component)', | ||||||
| @ -47,7 +47,7 @@ void addInputStories(Dashbook dashbook) { | |||||||
|           game: DoubleTapCallbacksExample(), |           game: DoubleTapCallbacksExample(), | ||||||
|         ); |         ); | ||||||
|       }, |       }, | ||||||
|       codeLink: baseLink('input/draggables_example.dart'), |       codeLink: baseLink('input/double_tap_callbacks_example.dart'), | ||||||
|       info: DoubleTapCallbacksExample.description, |       info: DoubleTapCallbacksExample.description, | ||||||
|     ) |     ) | ||||||
|     ..add( |     ..add( | ||||||
| @ -108,10 +108,10 @@ void addInputStories(Dashbook dashbook) { | |||||||
|       info: MultitapAdvancedExample.description, |       info: MultitapAdvancedExample.description, | ||||||
|     ) |     ) | ||||||
|     ..add( |     ..add( | ||||||
|       'Overlapping Tappables', |       'Overlapping TapCallbacks', | ||||||
|       (_) => GameWidget(game: OverlappingTappablesExample()), |       (_) => GameWidget(game: OverlappingTapCallbacksExample()), | ||||||
|       codeLink: baseLink('input/overlapping_tappables_example.dart'), |       codeLink: baseLink('input/overlapping_tap_callbacks_example.dart'), | ||||||
|       info: OverlappingTappablesExample.description, |       info: OverlappingTapCallbacksExample.description, | ||||||
|     ) |     ) | ||||||
|     ..add( |     ..add( | ||||||
|       'Gesture Hitboxes', |       'Gesture Hitboxes', | ||||||
|  | |||||||
| @ -4,7 +4,7 @@ import 'package:flame/extensions.dart'; | |||||||
| import 'package:flame/game.dart'; | import 'package:flame/game.dart'; | ||||||
| import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||||
| 
 | 
 | ||||||
| class OverlappingTappablesExample extends FlameGame { | class OverlappingTapCallbacksExample extends FlameGame { | ||||||
|   static const String description = ''' |   static const String description = ''' | ||||||
|     In this example we show you that events can choose to continue propagating |     In this example we show you that events can choose to continue propagating | ||||||
|     to underlying components. The middle green square continue to propagate the |     to underlying components. The middle green square continue to propagate the | ||||||
| @ -13,14 +13,19 @@ class OverlappingTappablesExample extends FlameGame { | |||||||
| 
 | 
 | ||||||
|   @override |   @override | ||||||
|   Future<void> onLoad() async { |   Future<void> onLoad() async { | ||||||
|     add(TappableSquare(position: Vector2(100, 100))); |     add(TapCallbacksSquare(position: Vector2(100, 100))); | ||||||
|     add(TappableSquare(position: Vector2(150, 150), continuePropagation: true)); |     add( | ||||||
|     add(TappableSquare(position: Vector2(100, 200))); |       TapCallbacksSquare( | ||||||
|  |         position: Vector2(150, 150), | ||||||
|  |         continuePropagation: true, | ||||||
|  |       ), | ||||||
|  |     ); | ||||||
|  |     add(TapCallbacksSquare(position: Vector2(100, 200))); | ||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| class TappableSquare extends RectangleComponent with TapCallbacks { | class TapCallbacksSquare extends RectangleComponent with TapCallbacks { | ||||||
|   TappableSquare({Vector2? position, this.continuePropagation = false}) |   TapCallbacksSquare({Vector2? position, this.continuePropagation = false}) | ||||||
|       : super( |       : super( | ||||||
|           position: position ?? Vector2.all(100), |           position: position ?? Vector2.all(100), | ||||||
|           size: Vector2.all(100), |           size: Vector2.all(100), | ||||||
		Reference in New Issue
	
	Block a user
	 Lukas Klingsbo
					Lukas Klingsbo