Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Fix naming of drag- and tap-callbacks examples #2873

Merged
merged 5 commits into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import 'package:flame/events.dart';
import 'package:flame/game.dart';
import 'package:flutter/material.dart' show Colors;

class DraggablesExample extends FlameGame {
class DragCallbacksExample extends FlameGame {
static const String description = '''
In this example we show you can use the `DragCallbacks` mixin on
`PositionComponent`s. Drag around the Embers and see their position
changing.
''';

DraggablesExample({required this.zoom});
DragCallbacksExample({required this.zoom});

final double zoom;
late final DraggableEmber square;
Expand All @@ -34,14 +34,14 @@ class DraggableEmber extends Ember with DragCallbacks {
@override
void update(double dt) {
super.update(dt);
debugColor = isDragged && findGame() is DraggablesExample
debugColor = isDragged && findGame() is DragCallbacksExample
luanpotter marked this conversation as resolved.
Show resolved Hide resolved
? Colors.greenAccent
: Colors.purple;
}

@override
void onDragUpdate(DragUpdateEvent event) {
if (findGame() is! DraggablesExample) {
if (findGame() is! DragCallbacksExample) {
spydon marked this conversation as resolved.
Show resolved Hide resolved
event.continuePropagation = true;
return;
}
Expand Down
22 changes: 11 additions & 11 deletions examples/lib/stories/input/input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:dashbook/dashbook.dart';
import 'package:examples/commons/commons.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/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/hardware_keyboard_example.dart';
import 'package:examples/stories/input/hover_callbacks_example.dart';
Expand All @@ -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/multitap_advanced_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/tap_callbacks_example.dart';
import 'package:flame/game.dart';
Expand All @@ -29,16 +29,16 @@ void addInputStories(Dashbook dashbook) {
info: TapCallbacksExample.description,
)
..add(
'Draggables',
'DragCallbacks',
(context) {
return GameWidget(
game: DraggablesExample(
game: DragCallbacksExample(
zoom: context.listProperty('zoom', 1, [0.5, 1, 1.5]),
),
);
},
codeLink: baseLink('input/draggables_example.dart'),
info: DraggablesExample.description,
codeLink: baseLink('input/drag_callbacks_example.dart'),
info: DragCallbacksExample.description,
)
..add(
'Double Tap (Component)',
Expand All @@ -47,7 +47,7 @@ void addInputStories(Dashbook dashbook) {
game: DoubleTapCallbacksExample(),
);
},
codeLink: baseLink('input/draggables_example.dart'),
codeLink: baseLink('input/double_tap_callbacks_example.dart'),
info: DoubleTapCallbacksExample.description,
)
..add(
Expand Down Expand Up @@ -108,10 +108,10 @@ void addInputStories(Dashbook dashbook) {
info: MultitapAdvancedExample.description,
)
..add(
'Overlapping Tappables',
(_) => GameWidget(game: OverlappingTappablesExample()),
codeLink: baseLink('input/overlapping_tappables_example.dart'),
info: OverlappingTappablesExample.description,
'Overlapping TapCallbacks',
(_) => GameWidget(game: OverlappingTapCallbacksExample()),
codeLink: baseLink('input/overlapping_tap_callbacks_example.dart'),
info: OverlappingTapCallbacksExample.description,
)
..add(
'Gesture Hitboxes',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:flame/extensions.dart';
import 'package:flame/game.dart';
import 'package:flutter/material.dart';

class OverlappingTappablesExample extends FlameGame {
class OverlappingTapCallbacksExample extends FlameGame {
static const String description = '''
In this example we show you that events can choose to continue propagating
to underlying components. The middle green square continue to propagate the
Expand All @@ -13,14 +13,15 @@ class OverlappingTappablesExample extends FlameGame {

@override
Future<void> onLoad() async {
add(TappableSquare(position: Vector2(100, 100)));
add(TappableSquare(position: Vector2(150, 150), continuePropagation: true));
add(TappableSquare(position: Vector2(100, 200)));
add(TapCallbacksSquare(position: Vector2(100, 100)));
add(TapCallbacksSquare(
position: Vector2(150, 150), continuePropagation: true));
spydon marked this conversation as resolved.
Show resolved Hide resolved
add(TapCallbacksSquare(position: Vector2(100, 200)));
}
}

class TappableSquare extends RectangleComponent with TapCallbacks {
TappableSquare({Vector2? position, this.continuePropagation = false})
class TapCallbacksSquare extends RectangleComponent with TapCallbacks {
TapCallbacksSquare({Vector2? position, this.continuePropagation = false})
: super(
position: position ?? Vector2.all(100),
size: Vector2.all(100),
Expand Down