mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-02 03:15:43 +08:00
docs: Deprecate TapDetector in favour of TapCallbacks (#2886)
Deprecate `TapDetector` in favour of `TapCallbacks`
This commit is contained in:
@ -10,7 +10,7 @@ import 'package:flame/palette.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class RaycastLightExample extends FlameGame
|
||||
with HasCollisionDetection, TapDetector, MouseMovementDetector {
|
||||
with HasCollisionDetection, TapCallbacks, MouseMovementDetector {
|
||||
static const description = '''
|
||||
In this example the raycast functionality is showcased by using it as a light
|
||||
source, if you move the mouse around the canvas the rays will be cast from its
|
||||
@ -88,9 +88,8 @@ with with mouse.
|
||||
}
|
||||
|
||||
@override
|
||||
void onTapDown(TapDownInfo info) {
|
||||
super.onTapDown(info);
|
||||
final origin = info.eventPosition.widget;
|
||||
void onTapDown(TapDownEvent event) {
|
||||
final origin = event.canvasPosition;
|
||||
isTapOriginCasted = origin == tapOrigin;
|
||||
tapOrigin = origin;
|
||||
}
|
||||
|
||||
@ -9,11 +9,7 @@ import 'package:flame/palette.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class RaytraceExample extends FlameGame
|
||||
with
|
||||
HasCollisionDetection,
|
||||
TapDetector,
|
||||
MouseMovementDetector,
|
||||
TapDetector {
|
||||
with HasCollisionDetection, MouseMovementDetector, TapCallbacks {
|
||||
static const description = '''
|
||||
In this example the raytrace functionality is showcased.
|
||||
Click to start sending out a ray which will bounce around to visualize how it
|
||||
@ -54,8 +50,9 @@ bounce on will appear.
|
||||
|
||||
bool isClicked = false;
|
||||
final extraChildren = <Component>[];
|
||||
|
||||
@override
|
||||
void onTap() {
|
||||
void onTapDown(_) {
|
||||
if (!isClicked) {
|
||||
isClicked = true;
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user