Skip to content

Commit

Permalink
Merge pull request #9 from vikgor/feature/checkpoint-height-fix
Browse files Browse the repository at this point in the history
Fix finish checkpoint height
  • Loading branch information
cocoatoucher authored Jul 15, 2023
2 parents bc1ecd9 + 4318182 commit 4724f8d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ class RestartAtCheckpointScene: BaseLevelScene {
spawnDirection: TransformNodeComponent.HeadingDirection.right)
let finishCheckpointEntity = EntityFactory.checkpointEntity(checkpoint: finishCheckpoint,
checkpointWidthInTiles: 3,
tileSize: tileSize)
tileSize: tileSize,
stretchesToTop: true)
addEntity(finishCheckpointEntity)

addEntity(gemCounterEntity)
Expand Down
8 changes: 5 additions & 3 deletions Sources/Entities/Convenience/EntityFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
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)
let checkpointComponent = CheckpointComponent(checkpoint: checkpoint, adjustsColliderSize: !stretchesToTop)
entity.addComponent(checkpointComponent)

let colliderWidth = CGFloat(checkpointWidthInTiles) * tileSize.width
let colliderHeight = stretchesToTop ? 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),
Expand Down

0 comments on commit 4724f8d

Please sign in to comment.