From a5638053c6184d5a40f2c801a25362abc9a85f9f Mon Sep 17 00:00:00 2001 From: MegaBrutal Date: Sun, 16 Sep 2018 03:15:00 +0200 Subject: [PATCH] Offscreen Teleportation modified: wgj58.js --- wgj58.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/wgj58.js b/wgj58.js index ad6bbf8..78cd42b 100644 --- a/wgj58.js +++ b/wgj58.js @@ -191,6 +191,11 @@ class GameNPC extends Phaser.Sprite { logic.player.offerInteraction(null); this.interactable = false; } + if ((this.teleport_instructions) && (game.physics.arcade.distanceBetween(this, logic.player) > (game.width + 200))) { + this.position = this.teleport_instructions.newPosition; + this.teleport_instructions.callback(this.teleport_instructions.callbackValue); + this.teleport_instructions = null; + } } actionTalk() { @@ -209,6 +214,11 @@ class GameNPC extends Phaser.Sprite { endTalk() { return true; } + + offscreenTeleportation(newPosition, callback, callbackValue) { + this.teleport_instructions = { newPosition: newPosition, callback: callback, callbackValue: callbackValue }; + console.log("Offscreen teleport request registered:", this.teleport_instructions); + } } class NPC_Clara extends GameNPC { @@ -437,7 +447,7 @@ class NPC_Saiki extends GameNPC { { actor: this, text: "Indeed. But this is the point. He's stuck in one place, cannot move. Like you in life. So you feel sympathy for him." }, { actor: logic.player, text: "You have a point." }, { actor: this, text: "I think I'll catch Carlos and talk to him. I always liked that guy but I didn't know he's such imaginative." } ] )); - //this.offscreenTeleportation(new Phaser.Point(logic.carlos.x + 128, logic.carlos.y), this.tpdone); + this.offscreenTeleportation(new Phaser.Point(logic.carlos.x, logic.carlos.y + 64), this.tpDone, this); } else { if (Phaser.Math.random() < 0.5) { @@ -495,6 +505,10 @@ class NPC_Saiki extends GameNPC { endTalk() { return (logic.carlos.alive); } + + tpDone(value) { + console.log("Woot-woot! Teleport complete:", value); + } } -- 2.34.1