Skip to content

Commit

Permalink
Fix bug when the regular camera isn't following a sprite
Browse files Browse the repository at this point in the history
  • Loading branch information
riknoll committed Aug 18, 2022
1 parent 70f5019 commit c932ef6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@ namespace splitScreen {
else {
const tm = game.currentScene().tileMap;

const realOffsetX = Math.clamp(0, tm.areaWidth(), this.realCamera.sprite.x - 40);
shiftScreen(this.realScreen, Math.min(realOffsetX - this.realCamera.offsetX, 80));
if (this.realCamera.sprite) {
const realOffsetX = Math.clamp(0, tm.areaWidth(), this.realCamera.sprite.x - 40);
shiftScreen(this.realScreen, Math.min(realOffsetX - this.realCamera.offsetX, 80));
}
else {
shiftScreen(this.realScreen, 40);
}

const fakeOffsetX = Math.clamp(0, tm.areaWidth(), this.fakeCamera.sprite.x - 40);

Expand Down

0 comments on commit c932ef6

Please sign in to comment.