chore: Remove 1.8.0 deprecations (#2538)

Removes all the deprecated methods before 1.8.0 release.
This commit is contained in:
Lukas Klingsbo
2023-05-22 19:01:55 +02:00
committed by GitHub
parent 6e1d5466aa
commit 2d45d2be39
139 changed files with 1224 additions and 1084 deletions

View File

@ -1,8 +1,8 @@
import 'dart:math';
import 'package:flame/components.dart';
import 'package:flame/effects.dart';
import 'package:flame/game.dart';
import 'package:flame/geometry.dart';
import 'package:flame_noise/flame_noise.dart';
import 'package:flutter/material.dart';
@ -21,10 +21,19 @@ class MoveEffectExample extends FlameGame {
an arbitrary path using `MoveEffect.along`.
''';
final world = World();
late final CameraComponent cameraComponent;
@override
void onMount() {
void onLoad() {
const tau = Transform2D.tau;
camera.viewport = FixedResolutionViewport(Vector2(400, 600));
cameraComponent = CameraComponent.withFixedResolution(
world: world,
width: 400,
height: 600,
);
cameraComponent.viewfinder.anchor = Anchor.topLeft;
addAll([world, cameraComponent]);
final paint1 = Paint()
..style = PaintingStyle.stroke
@ -37,7 +46,7 @@ class MoveEffectExample extends FlameGame {
final paint3 = Paint()..color = const Color(0xffb372dc);
// Red square, moving back and forth
add(
world.add(
RectangleComponent.square(
position: Vector2(20, 50),
size: 20,
@ -56,7 +65,7 @@ class MoveEffectExample extends FlameGame {
);
// Green square, moving and jumping
add(
world.add(
RectangleComponent.square(
position: Vector2(20, 150),
size: 20,
@ -87,7 +96,8 @@ class MoveEffectExample extends FlameGame {
),
);
add(
// Purple square, vibrating from two noise controllers.
world.add(
RectangleComponent.square(
size: 15,
position: Vector2(40, 240),
@ -110,6 +120,29 @@ class MoveEffectExample extends FlameGame {
),
);
// A circle of moving rectangles.
final path2 = Path()..addOval(const Rect.fromLTRB(80, 230, 320, 470));
for (var i = 0; i < 20; i++) {
world.add(
RectangleComponent.square(size: 10)
..position = Vector2(i * 10, 0)
..paint = (Paint()..color = Colors.tealAccent)
..add(
MoveAlongPathEffect(
path2,
EffectController(
duration: 6,
startDelay: i * 0.3,
infinite: true,
),
absolute: true,
oriented: true,
),
),
);
}
// A star of moving rectangles.
final path1 = Path()..moveTo(200, 250);
for (var i = 1; i <= 5; i++) {
final x = 200 + 100 * sin(i * tau * 2 / 5);
@ -117,9 +150,9 @@ class MoveEffectExample extends FlameGame {
path1.lineTo(x, y);
}
for (var i = 0; i < 40; i++) {
add(
world.add(
CircleComponent(radius: 5)
..position = Vector2(0, -1000)
..position = Vector2(i * 10, 0)
..add(
MoveAlongPathEffect(
path1,
@ -133,24 +166,5 @@ class MoveEffectExample extends FlameGame {
),
);
}
final path2 = Path()..addOval(const Rect.fromLTRB(80, 230, 320, 470));
for (var i = 0; i < 20; i++) {
add(
RectangleComponent.square(size: 10)
..paint = (Paint()..color = Colors.tealAccent)
..add(
MoveAlongPathEffect(
path2,
EffectController(
duration: 6,
startDelay: i * 0.3,
infinite: true,
),
oriented: true,
),
),
);
}
}
}