From 6fb9425f4fd7c3ebddb976525396ac499188b9bb Mon Sep 17 00:00:00 2001 From: v-gordienko Date: Sun, 30 Apr 2023 21:09:29 -0300 Subject: [PATCH 1/2] Fix finish checkpoint height --- .../Scenes/Level Logic/RestartAtCheckpointScene.swift | 3 ++- Sources/Entities/Convenience/EntityFactory.swift | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Demo/Shared/Scenes/Level Logic/RestartAtCheckpointScene.swift b/Demo/Shared/Scenes/Level Logic/RestartAtCheckpointScene.swift index dc3ddeb..4cc6733 100644 --- a/Demo/Shared/Scenes/Level Logic/RestartAtCheckpointScene.swift +++ b/Demo/Shared/Scenes/Level Logic/RestartAtCheckpointScene.swift @@ -58,7 +58,8 @@ class RestartAtCheckpointScene: BaseLevelScene { spawnDirection: TransformNodeComponent.HeadingDirection.right) let finishCheckpointEntity = EntityFactory.checkpointEntity(checkpoint: finishCheckpoint, checkpointWidthInTiles: 3, - tileSize: tileSize) + tileSize: tileSize, + isFinish: true) addEntity(finishCheckpointEntity) addEntity(gemCounterEntity) diff --git a/Sources/Entities/Convenience/EntityFactory.swift b/Sources/Entities/Convenience/EntityFactory.swift index 5fd6573..56c3d82 100644 --- a/Sources/Entities/Convenience/EntityFactory.swift +++ b/Sources/Entities/Convenience/EntityFactory.swift @@ -112,17 +112,19 @@ public class EntityFactory { /// - tileSize: Tile size of the scene. public static func checkpointEntity(checkpoint: Checkpoint, checkpointWidthInTiles: Int, - tileSize: CGSize) -> GlideEntity { + tileSize: CGSize, + isFinish: Bool = false) -> GlideEntity { let entity = GlideEntity(initialNodePosition: checkpoint.bottomLeftPosition.point(with: tileSize)) entity.name = "Checkpoint-\(checkpoint.id)" entity.transform.usesProposedPosition = false - let checkpointComponent = CheckpointComponent(checkpoint: checkpoint) + let checkpointComponent = CheckpointComponent(checkpoint: checkpoint, adjustsColliderSize: !isFinish) entity.addComponent(checkpointComponent) let colliderWidth = CGFloat(checkpointWidthInTiles) * tileSize.width + let colliderHeight = isFinish ? CGFloat(checkpointWidthInTiles) * tileSize.height : 0 let colliderComponent = ColliderComponent(categoryMask: GlideCategoryMask.snappable, - size: CGSize(width: colliderWidth, height: 0), + size: CGSize(width: colliderWidth, height: colliderHeight), offset: .zero, leftHitPointsOffsets: (0, 0), rightHitPointsOffsets: (0, 0), From 4318182362182f1f6a10ab336f7de9d21d5fb713 Mon Sep 17 00:00:00 2001 From: vikgor Date: Tue, 11 Jul 2023 23:58:17 +0600 Subject: [PATCH 2/2] Rename checkpoint finish parameter --- .../Scenes/Level Logic/RestartAtCheckpointScene.swift | 2 +- Sources/Entities/Convenience/EntityFactory.swift | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Demo/Shared/Scenes/Level Logic/RestartAtCheckpointScene.swift b/Demo/Shared/Scenes/Level Logic/RestartAtCheckpointScene.swift index 4cc6733..e9e40d1 100644 --- a/Demo/Shared/Scenes/Level Logic/RestartAtCheckpointScene.swift +++ b/Demo/Shared/Scenes/Level Logic/RestartAtCheckpointScene.swift @@ -59,7 +59,7 @@ class RestartAtCheckpointScene: BaseLevelScene { let finishCheckpointEntity = EntityFactory.checkpointEntity(checkpoint: finishCheckpoint, checkpointWidthInTiles: 3, tileSize: tileSize, - isFinish: true) + stretchesToTop: true) addEntity(finishCheckpointEntity) addEntity(gemCounterEntity) diff --git a/Sources/Entities/Convenience/EntityFactory.swift b/Sources/Entities/Convenience/EntityFactory.swift index 56c3d82..137e957 100644 --- a/Sources/Entities/Convenience/EntityFactory.swift +++ b/Sources/Entities/Convenience/EntityFactory.swift @@ -113,16 +113,16 @@ public class EntityFactory { public static func checkpointEntity(checkpoint: Checkpoint, checkpointWidthInTiles: Int, tileSize: CGSize, - isFinish: Bool = false) -> GlideEntity { + stretchesToTop: Bool = false) -> GlideEntity { let entity = GlideEntity(initialNodePosition: checkpoint.bottomLeftPosition.point(with: tileSize)) entity.name = "Checkpoint-\(checkpoint.id)" entity.transform.usesProposedPosition = false - let checkpointComponent = CheckpointComponent(checkpoint: checkpoint, adjustsColliderSize: !isFinish) + let checkpointComponent = CheckpointComponent(checkpoint: checkpoint, adjustsColliderSize: !stretchesToTop) entity.addComponent(checkpointComponent) let colliderWidth = CGFloat(checkpointWidthInTiles) * tileSize.width - let colliderHeight = isFinish ? CGFloat(checkpointWidthInTiles) * tileSize.height : 0 + let colliderHeight = stretchesToTop ? CGFloat(checkpointWidthInTiles) * tileSize.height : 0 let colliderComponent = ColliderComponent(categoryMask: GlideCategoryMask.snappable, size: CGSize(width: colliderWidth, height: colliderHeight), offset: .zero,