Skip to content

Commit 8c2c1f6

Browse files
authored
feat: upgrade to flame 1.28 (#81)
1 parent cf11d35 commit 8c2c1f6

22 files changed

+195
-160
lines changed

examples/standard_platformer/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
*.swp
66
.DS_Store
77
.atom/
8+
.build/
89
.buildlog/
910
.history
1011
.svn/
12+
.swiftpm/
1113
migrate_working_dir/
1214

1315
# IntelliJ related

examples/standard_platformer/lib/door.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import 'package:leap/leap.dart';
33
import 'package:leap_standard_platformer/main.dart';
44
import 'package:tiled/tiled.dart';
55

6-
class Door extends PhysicalEntity with HasGameRef<ExamplePlatformerLeapGame> {
6+
class Door extends PhysicalEntity
7+
with HasGameReference<ExamplePlatformerLeapGame> {
78
Door(TiledObject object, ObjectGroup layer)
89
: super(
910
position: Vector2(object.x, object.y),

examples/standard_platformer/lib/hud.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import 'package:flame/components.dart';
22
import 'package:flutter/material.dart';
33
import 'package:leap_standard_platformer/main.dart';
44

5-
class Hud extends PositionComponent with HasGameRef<ExamplePlatformerLeapGame> {
5+
class Hud extends PositionComponent
6+
with HasGameReference<ExamplePlatformerLeapGame> {
67
Hud() {
78
final textPaint = TextPaint(style: textStyle);
89
textComponent = TextComponent(textRenderer: textPaint);
@@ -24,6 +25,6 @@ class Hud extends PositionComponent with HasGameRef<ExamplePlatformerLeapGame> {
2425
@override
2526
void update(double dt) {
2627
super.update(dt);
27-
textComponent.text = 'Coins: ${gameRef.player?.coins ?? 0}';
28+
textComponent.text = 'Coins: ${game.player?.coins ?? 0}';
2829
}
2930
}

examples/standard_platformer/lib/info_text.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class InfoText extends PhysicalEntity {
2525
textRenderer: TextPaint(
2626
style: TextStyle(
2727
fontSize: 8,
28-
backgroundColor: Colors.black.withOpacity(0.4),
28+
backgroundColor: Colors.black.withValues(alpha: 0.4),
2929
),
3030
),
3131
);

examples/standard_platformer/lib/player.dart

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import 'package:leap_standard_platformer/info_text.dart';
88
import 'package:leap_standard_platformer/main.dart';
99

1010
class Player extends JumperCharacter
11-
with HasGameRef<ExamplePlatformerLeapGame>, HasHealth, HasAnimationGroup {
11+
with
12+
HasGameReference<ExamplePlatformerLeapGame>,
13+
HasHealth,
14+
HasAnimationGroup {
1215
Player() {
1316
// Behaviors, ordering is important for processing
1417
// collision detection and reacting to inputs
@@ -87,9 +90,9 @@ class Player extends JumperCharacter
8790
void updateCollisionInteractions(double dt) {}
8891

8992
void _checkForLevelCompletion() {
90-
final coinsLeft = gameRef.leapMap.children.whereType<Coin>().length;
93+
final coinsLeft = game.leapMap.children.whereType<Coin>().length;
9194
if (coinsLeft <= 1) {
92-
gameRef.levelCleared();
95+
game.levelCleared();
9396
}
9497
}
9598
}
@@ -294,12 +297,12 @@ enum _AnimationState { idle, walk, jump, fall, death, ladder }
294297

295298
class PlayerSpriteAnimation
296299
extends AnchoredAnimationGroup<_AnimationState, Player>
297-
with HasGameRef<LeapGame> {
300+
with HasGameReference<LeapGame> {
298301
PlayerSpriteAnimation() : super(scale: Vector2.all(2));
299302

300303
@override
301304
Future<void>? onLoad() async {
302-
final spritesheet = await gameRef.images.load('player_spritesheet.png');
305+
final spritesheet = await game.images.load('player_spritesheet.png');
303306

304307
animations = {
305308
_AnimationState.idle: SpriteAnimation.fromFrameData(

examples/standard_platformer/lib/welcome_dialog.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class WelcomeDialog extends TextBoxComponent {
3131
rect = Rect.fromLTWH(0, 0, width, height);
3232
}
3333

34-
final bgPaint = Paint()..color = Colors.blueGrey.withOpacity(0.8);
34+
final bgPaint = Paint()..color = Colors.blueGrey.withValues(alpha: 0.8);
3535
final borderPaint = Paint()
3636
..color = Colors.black
3737
..style = PaintingStyle.stroke

examples/standard_platformer/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
ignoresPersistentStateOnLaunch = "NO"
4949
debugDocumentVersioning = "YES"
5050
debugServiceExtension = "internal"
51+
enableGPUValidationMode = "1"
5152
allowLocationSimulation = "YES">
5253
<BuildableProductRunnable
5354
runnableDebuggingMode = "0">

examples/standard_platformer/macos/Runner/AppDelegate.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@ class AppDelegate: FlutterAppDelegate {
66
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
77
return true
88
}
9+
10+
override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
11+
return true
12+
}
913
}

0 commit comments

Comments
 (0)