From 72da30e5bd24add849e0020ebb47ffb0abf7878b Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 5 Jan 2017 10:15:50 -0800 Subject: [PATCH] Update bow.js to use setInterval --- .../Toybox/towerDefense/bow/bow.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/unpublishedScripts/DomainContent/Toybox/towerDefense/bow/bow.js b/unpublishedScripts/DomainContent/Toybox/towerDefense/bow/bow.js index 3846e7ca50..6d9822a72e 100644 --- a/unpublishedScripts/DomainContent/Toybox/towerDefense/bow/bow.js +++ b/unpublishedScripts/DomainContent/Toybox/towerDefense/bow/bow.js @@ -222,23 +222,30 @@ getControllerWorldLocation = function (handController, doOffset) { setEntityCustomData('grabbableKey', this.entityID, data); this.initString(); + + var self = this; + this.intervalID = Script.setInterval(function() { self.update(); }, 11); }, - continueEquip: function(entityID, args) { - this.deltaTime = checkInterval(); + update: function(entityID) { + var self = this; + self.deltaTime = checkInterval(); //debounce during debugging -- maybe we're updating too fast? if (USE_DEBOUNCE === true) { - this.sinceLastUpdate = this.sinceLastUpdate + this.deltaTime; + self.sinceLastUpdate = self.sinceLastUpdate + self.deltaTime; - if (this.sinceLastUpdate > 60) { - this.sinceLastUpdate = 0; + if (self.sinceLastUpdate > 60) { + self.sinceLastUpdate = 0; } else { return; } } - this.checkStringHand(); + self.checkStringHand(); }, releaseEquip: function(entityID, args) { + //Script.update.disconnect(this, this.update); + Script.clearInterval(this.intervalID); + Messages.sendLocalMessage('Hifi-Hand-Disabler', "none"); this.stringDrawn = false;