diff --git a/examples/toys/bubblewand/bubble.js b/examples/toys/bubblewand/bubble.js index 2a0690c921..91a72642d3 100644 --- a/examples/toys/bubblewand/bubble.js +++ b/examples/toys/bubblewand/bubble.js @@ -12,7 +12,7 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -(function() { +(function() { << << << < HEAD Script.include("../../utilities.js"); Script.include("../../libraries/utils.js"); @@ -41,20 +41,34 @@ if (tmpProperties.position.x !== 0 && tmpProperties.position.y !== 0 && tmpProperties.position.z !== 0) { properties = tmpProperties; } + }; this.unload = function(entityID) { Script.update.disconnect(this.internalUpdate); var position = properties.position; - _this.endOfBubble(position); + _t.endOfBubble(position); + // print('UNLOAD PROPS' + JSON.stringify(position)); }; this.endOfBubble = function(position) { + this.createBurstParticles(position); - }; + this.burstBubbleSound(position); + } + + this.burstBubbleSound = function(position) { + var audioOptions = { + volume: 0.5, + position: position + } + Audio.playSound(POP_SOUNDS[randInt(0, 4)], audioOptions); + + } this.createBurstParticles = function(position) { + var _t = this; //get the current position of the bubble var position = properties.position; //var orientation = properties.orientation; diff --git a/examples/toys/bubblewand/createWand.js b/examples/toys/bubblewand/createWand.js index 8403ba8516..7386c8b26f 100644 --- a/examples/toys/bubblewand/createWand.js +++ b/examples/toys/bubblewand/createWand.js @@ -14,27 +14,32 @@ Script.include("../../utilities.js"); Script.include("../../libraries/utils.js"); + var WAND_MODEL = 'http://hifi-public.s3.amazonaws.com/james/bubblewand/models/wand/wand.fbx'; var WAND_COLLISION_SHAPE = 'http://hifi-public.s3.amazonaws.com/james/bubblewand/models/wand/collisionHull.obj'; var WAND_SCRIPT_URL = Script.resolvePath("wand.js?"+randInt(0,4000)); //create the wand in front of the avatar var center = Vec3.sum(MyAvatar.position, Vec3.multiply(1, Quat.getFront(Camera.getOrientation()))); + var wand = Entities.addEntity({ type: "Model", modelURL: WAND_MODEL, - position: center, - dimensions: { - x: 0.05, - y: 0.5, - z: 0.05 - }, - //must be enabled to be grabbable in the physics engine - collisionsWillMove: true, - compoundShapeURL: WAND_COLLISION_SHAPE, - script: WAND_SCRIPT_URL -}); + var wand = Entities.addEntity({ + type: "Model", + modelURL: wandModel, + position: center, + dimensions: { + x: 0.05, + y: 0.5, + z: 0.05 + }, + //must be enabled to be grabbable in the physics engine + collisionsWillMove: true, + compoundShapeURL: WAND_COLLISION_SHAPE, + script: WAND_SCRIPT_URL + }); function cleanup() { Entities.deleteEntity(wand); }