[flutter] Fix Flame examples, AppDelegate warning on macOS, debug logging in AnimationStateEventManager

This commit is contained in:
Mario Zechner 2025-07-30 09:57:57 +02:00
parent 4225214caf
commit 1570962903
3 changed files with 12 additions and 8 deletions

View File

@ -125,7 +125,7 @@ class SimpleFlameExample extends FlameGame {
);
// Set the "walk" animation on track 0 in looping mode
spineboy.animationState.setAnimationByName(0, "walk", true);
spineboy.animationState.setAnimation(0, "walk", true);
await add(spineboy);
}
@ -150,10 +150,10 @@ class DragonExample extends FlameGame {
drawable,
scale: Vector2(0.4, 0.4),
anchor: Anchor.center,
position: Vector2(size.x / 2, size.y / 2 - 150),
position: Vector2(size.x / 2, size.y / 2),
);
// Set the "walk" animation on track 0 in looping mode
dragon.animationState.setAnimationByName(0, "flying", true);
dragon.animationState.setAnimation(0, "flying", true);
await add(dragon);
}
@ -186,7 +186,7 @@ class PreloadAndShareSpineDataExample extends FlameGame {
final scale = 0.1 + rng.nextDouble() * 0.2;
final position = Vector2(rng.nextDouble() * size.x, rng.nextDouble() * size.y);
final spineboy = SpineComponent(drawable, scale: Vector2(scale, scale), position: position);
spineboy.animationState.setAnimationByName(0, "walk", true);
spineboy.animationState.setAnimation(0, "walk", true);
spineboys.add(spineboy);
await add(spineboy);
}

View File

@ -6,4 +6,8 @@ class AppDelegate: FlutterAppDelegate {
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
return true
}
override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
return true
}
}

View File

@ -262,7 +262,7 @@ class AnimationStateEventManager {
listeners.remove(entryKey);
} else {
listeners[entryKey] = listener;
print('DEBUG: Registered listener for TrackEntry at address: $entryKey for AnimationState at address: $stateKey');
// print('DEBUG: Registered listener for TrackEntry at address: $entryKey for AnimationState at address: $stateKey');
}
}
@ -271,9 +271,9 @@ class AnimationStateEventManager {
final entryKey = entry.nativePtr.address;
final listener = _trackEntryListeners[stateKey]?[entryKey];
if (listener == null) {
print('DEBUG: No listener found for TrackEntry at address: $entryKey in AnimationState at address: $stateKey');
print('DEBUG: Available state keys: ${_trackEntryListeners.keys.toList()}');
print('DEBUG: Available entry keys for state $stateKey: ${_trackEntryListeners[stateKey]?.keys.toList()}');
// print('DEBUG: No listener found for TrackEntry at address: $entryKey in AnimationState at address: $stateKey');
// print('DEBUG: Available state keys: ${_trackEntryListeners.keys.toList()}');
// print('DEBUG: Available entry keys for state $stateKey: ${_trackEntryListeners[stateKey]?.keys.toList()}');
}
return listener;
}