mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-01 19:12:31 +08:00
docs: Deprecate TapDetector in favour of TapCallbacks (#2886)
Deprecate `TapDetector` in favour of `TapCallbacks`
This commit is contained in:
@ -4,7 +4,6 @@ import 'package:flame/components.dart';
|
||||
import 'package:flame/events.dart';
|
||||
import 'package:flame/extensions.dart';
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:flame/input.dart';
|
||||
import 'package:flame_network_assets/flame_network_assets.dart';
|
||||
import 'package:flutter/material.dart' hide Image;
|
||||
|
||||
@ -12,7 +11,7 @@ void main() {
|
||||
runApp(const GameWidget.controlled(gameFactory: MyGame.new));
|
||||
}
|
||||
|
||||
class MyGame extends FlameGame with TapDetector {
|
||||
class MyGame extends FlameGame with TapCallbacks {
|
||||
final networkImages = FlameNetworkImages();
|
||||
late Image playerSprite;
|
||||
|
||||
@ -24,7 +23,7 @@ class MyGame extends FlameGame with TapDetector {
|
||||
}
|
||||
|
||||
@override
|
||||
void onTapUp(TapUpInfo info) {
|
||||
void onTapUp(TapUpEvent event) {
|
||||
add(
|
||||
SpriteAnimationComponent.fromFrameData(
|
||||
playerSprite,
|
||||
@ -35,7 +34,7 @@ class MyGame extends FlameGame with TapDetector {
|
||||
),
|
||||
size: Vector2(100, 50),
|
||||
anchor: Anchor.center,
|
||||
position: info.eventPosition.widget,
|
||||
position: event.canvasPosition,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user