mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-02 03:15:43 +08:00
chore: Remove 1.8.0 deprecations (#2538)
Removes all the deprecated methods before 1.8.0 release.
This commit is contained in:
@ -1,25 +1,31 @@
|
||||
import 'package:examples/commons/ember.dart';
|
||||
import 'package:flame/camera.dart';
|
||||
import 'package:flame/events.dart';
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:flutter/material.dart' show Colors;
|
||||
|
||||
class DraggablesExample extends FlameGame {
|
||||
static const String description = '''
|
||||
In this example we show you can use the `Draggable` mixin on
|
||||
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});
|
||||
|
||||
final world = World();
|
||||
late final CameraComponent cameraComponent;
|
||||
final double zoom;
|
||||
late final DraggableEmber square;
|
||||
|
||||
DraggablesExample({required this.zoom});
|
||||
|
||||
@override
|
||||
Future<void> onLoad() async {
|
||||
camera.zoom = zoom;
|
||||
add(square = DraggableEmber());
|
||||
add(DraggableEmber()..y = 350);
|
||||
cameraComponent = CameraComponent(world: world);
|
||||
cameraComponent.viewfinder.zoom = zoom;
|
||||
addAll([cameraComponent, world]);
|
||||
|
||||
world.add(square = DraggableEmber());
|
||||
world.add(DraggableEmber()..y = 350);
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,28 +35,24 @@ class DraggableEmber extends Ember with DragCallbacks {
|
||||
@override
|
||||
bool debugMode = true;
|
||||
|
||||
DraggableEmber({Vector2? position})
|
||||
: super(
|
||||
position: position ?? Vector2.all(100),
|
||||
size: Vector2.all(100),
|
||||
);
|
||||
DraggableEmber({super.position}) : super(size: Vector2.all(100));
|
||||
|
||||
@override
|
||||
void update(double dt) {
|
||||
super.update(dt);
|
||||
debugColor = isDragged && parent is DraggablesExample
|
||||
debugColor = isDragged && findGame() is DraggablesExample
|
||||
? Colors.greenAccent
|
||||
: Colors.purple;
|
||||
}
|
||||
|
||||
@override
|
||||
void onDragUpdate(DragUpdateEvent event) {
|
||||
if (parent is! DraggablesExample) {
|
||||
if (findGame() is! DraggablesExample) {
|
||||
event.continuePropagation = true;
|
||||
return;
|
||||
}
|
||||
|
||||
position.add(event.localPosition);
|
||||
position.add(event.delta);
|
||||
event.continuePropagation = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user