From 68e03a08c00561f75ce5b86db140cf7eff7d7895 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Tue, 5 Jan 2016 15:43:49 -0800 Subject: [PATCH 1/2] targets fix --- examples/toybox/ping_pong_gun/wallTarget.js | 30 ++++++++++++--------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/examples/toybox/ping_pong_gun/wallTarget.js b/examples/toybox/ping_pong_gun/wallTarget.js index 26e8d320a8..0b97fb546a 100644 --- a/examples/toybox/ping_pong_gun/wallTarget.js +++ b/examples/toybox/ping_pong_gun/wallTarget.js @@ -17,6 +17,7 @@ } Target.prototype = { + hasBecomePhysical: false, hasPlayedSound: false, preload: function(entityID) { this.entityID = entityID; @@ -24,19 +25,22 @@ this.hitSound = SoundCache.getSound(SOUND_URL); }, collisionWithEntity: function(me, otherEntity) { - var position = Entities.getEntityProperties(me, "position").position; - Entities.editEntity(me, { - gravity: { - x: 0, - y: -9.8, - z: 0 - }, - velocity: { - x: 0, - y: -0.01, - z: 0 - } - }); + if (this.hasBecomePhysical === false) { + var position = Entities.getEntityProperties(me, "position").position; + Entities.editEntity(me, { + gravity: { + x: 0, + y: -9.8, + z: 0 + }, + velocity: { + x: 0, + y: -0.01, + z: 0 + } + }); + this.hasBecomePhysical = true; + } if (this.hasPlayedSound === false) { this.audioInjector = Audio.playSound(this.hitSound, { From 7c18359fba77bd2bc518906a4642aa944de2310b Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Tue, 5 Jan 2016 16:17:11 -0800 Subject: [PATCH 2/2] cleanup --- examples/toybox/ping_pong_gun/wallTarget.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/examples/toybox/ping_pong_gun/wallTarget.js b/examples/toybox/ping_pong_gun/wallTarget.js index 0b97fb546a..5aa46b1dc7 100644 --- a/examples/toybox/ping_pong_gun/wallTarget.js +++ b/examples/toybox/ping_pong_gun/wallTarget.js @@ -17,15 +17,14 @@ } Target.prototype = { - hasBecomePhysical: false, - hasPlayedSound: false, + hasBecomeActive: false, preload: function(entityID) { this.entityID = entityID; var SOUND_URL = "http://hifi-public.s3.amazonaws.com/sounds/Clay_Pigeon_02.L.wav"; this.hitSound = SoundCache.getSound(SOUND_URL); }, collisionWithEntity: function(me, otherEntity) { - if (this.hasBecomePhysical === false) { + if (this.hasBecomeActive === false) { var position = Entities.getEntityProperties(me, "position").position; Entities.editEntity(me, { gravity: { @@ -39,16 +38,13 @@ z: 0 } }); - this.hasBecomePhysical = true; - } - if (this.hasPlayedSound === false) { this.audioInjector = Audio.playSound(this.hitSound, { position: position, volume: 0.5 }); - this.hasPlayedSound = true; + this.hasBecomeActive = true; }