From f8848c24f7dc708d3e2e0f40d60b15cf4dfcf3da Mon Sep 17 00:00:00 2001 From: plissken2013es Date: Thu, 30 Jun 2016 12:20:57 +0200 Subject: [PATCH] Added protection from null/undefined actor parameter to "setOpponentLive" method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I found that when you wait for the first cutscene and credits to pass, the game tries to start the "demo" level 0. But it has no guards[1] defined, so the it crashes leaving this error on the console: "phaser.js:74099 TypeError: Cannot read property 'charName' of undefined(…)xhr.onload @ phaser.js:74099" I added a protection for this case. --- src/Interface.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Interface.js b/src/Interface.js index 4674646..e4e048c 100644 --- a/src/Interface.js +++ b/src/Interface.js @@ -71,8 +71,7 @@ PrinceJS.Interface.prototype = { }, setOpponentLive: function(actor) { - - if (actor.charName == 'skeleton') return; + if (!actor || actor.charName == 'skeleton') return; this.oppHPActive = actor.health; for (var i=actor.health; i > 0; i--) {