Update bow.js to use setInterval

This commit is contained in:
Ryan Huffman 2017-01-05 10:15:50 -08:00
parent 410271a5b6
commit 72da30e5bd

View file

@ -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;