diff --git a/example/lib/game.dart b/example/lib/game.dart index e9cc968..e9d7dc8 100644 --- a/example/lib/game.dart +++ b/example/lib/game.dart @@ -669,7 +669,10 @@ class Player extends SpriteComponent ) { final myCenter = boundingBox.aabbCenter; if (other is GameCollideable || other is CellLayer) { - if (other is GameCollideable) { + if (game.player == this) { + position.setFrom(positionNoCollision); + game.camera.updateTree(0.01); + } else if (other is GameCollideable) { final diffX = myCenter.x - other.boundingBox.aabbCenter.x; if (diffX < 0) { canMoveRight = false; diff --git a/example/pubspec.yaml b/example/pubspec.yaml index a7a5429..7f24c30 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -29,7 +29,7 @@ environment: # the latest version available on pub.dev. To see which dependencies have newer # versions available, run `flutter pub outdated`. dependencies: - flame: ^1.10.1 + flame: ^1.12.0 flame_spatial_grid: #0.8.0 path: ../ flame_message_stream: 0.0.2 diff --git a/lib/src/components/layers/cell_trail_layer.dart b/lib/src/components/layers/cell_trail_layer.dart index 046d1fd..7499687 100644 --- a/lib/src/components/layers/cell_trail_layer.dart +++ b/lib/src/components/layers/cell_trail_layer.dart @@ -220,8 +220,8 @@ class CellTrailLayer extends CellStaticLayer { if (fadeOutConfig.isFadeOut) { _fadeOutDt += dt; + isUpdateNeeded = true; if (doFadeOut) { - isUpdateNeeded = true; updateLayer(dt); } } diff --git a/lib/src/core/has_spatial_grid_framework.dart b/lib/src/core/has_spatial_grid_framework.dart index 0123942..f6123ca 100644 --- a/lib/src/core/has_spatial_grid_framework.dart +++ b/lib/src/core/has_spatial_grid_framework.dart @@ -689,10 +689,10 @@ mixin HasSpatialGridFramework on FlameGame _collectDt(dt); tickersManager.update(dt); - collisionDetection.dt = dt; - collisionDetection.run(); super.update(dt); + collisionDetection.dt = dt; + collisionDetection.run(); } } else { final stopwatch = Stopwatch()..start(); @@ -934,6 +934,15 @@ mixin HasSpatialGridFramework on FlameGame this, ); progressManager.setProgress(100); + const dt = 0.001; + _loadWholeMap(); + _buildNewCells(); + _runScheduledLayerOperations(); + _collectDt(dt); + + tickersManager.update(dt); + collisionDetection.dt = dt; + collisionDetection.run(); _gameInitializationFinished = true; onInitializationDone(); diff --git a/pubspec.yaml b/pubspec.yaml index 3c07676..eb811d4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -7,7 +7,7 @@ environment: sdk: '>=3.0.0 <4.0.0' dependencies: - flame: ^1.10.1 + flame: ^1.12.0 flame_tiled: ^1.12.0 meta: ^1.8.0 isolate_manager: ^4.1.3