From 8d17e1f963830a35b6140225ea322d2460254519 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Mon, 30 Sep 2013 12:17:07 +0100 Subject: [PATCH] Sound duration fixes. --- README.md | 2 +- src/physics/arcade/ArcadePhysics.js | 4 ++-- src/sound/Sound.js | 17 +++++++++++------ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 400916e6b..39287eb0b 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ Version 1.0.7 (in progress in the dev branch) * Fixed Particle Emitters when using Emitter width/height (thanks XekeDeath) * Made animation looping more robust when skipping frames (thanks XekeDeath) * Fix for incorrect new particle positioning (issue #73) (thanks cottonflop) - +* Added support for Body.maxVelocity (thanks cocoademon) * TODO: addMarker hh:mm:ss:ms * TODO: Direction constants diff --git a/src/physics/arcade/ArcadePhysics.js b/src/physics/arcade/ArcadePhysics.js index 57eb4b633..1402007a5 100644 --- a/src/physics/arcade/ArcadePhysics.js +++ b/src/physics/arcade/ArcadePhysics.js @@ -51,13 +51,13 @@ Phaser.Physics.Arcade.prototype = { body.rotation += body.angularVelocity * this.game.time.physicsElapsed; // Horizontal - this._velocityDelta = (this.computeVelocity(1, body, body.velocity.x, body.acceleration.x, body.drag.x) - body.velocity.x) / 2; + this._velocityDelta = (this.computeVelocity(1, body, body.velocity.x, body.acceleration.x, body.drag.x, body.maxVelocity.x) - body.velocity.x) / 2; body.velocity.x += this._velocityDelta; this._delta = body.velocity.x * this.game.time.physicsElapsed; body.x += this._delta; // Vertical - this._velocityDelta = (this.computeVelocity(2, body, body.velocity.y, body.acceleration.y, body.drag.y) - body.velocity.y) / 2; + this._velocityDelta = (this.computeVelocity(2, body, body.velocity.y, body.acceleration.y, body.drag.y, body.maxVelocity.y) - body.velocity.y) / 2; body.velocity.y += this._velocityDelta; this._delta = body.velocity.y * this.game.time.physicsElapsed; body.y += this._delta; diff --git a/src/sound/Sound.js b/src/sound/Sound.js index 98fcd8aed..6a45bc7bc 100644 --- a/src/sound/Sound.js +++ b/src/sound/Sound.js @@ -203,6 +203,7 @@ Phaser.Sound.prototype = { stop: start + duration, volume: volume, duration: duration, + durationMS: duration * 1000, loop: loop }; @@ -293,12 +294,13 @@ Phaser.Sound.prototype = { if (this.isPlaying == true && forceRestart == false && this.override == false) { // Use Restart instead + console.log('Use Restart instead'); return; } if (this.isPlaying && this.override) { - // console.log('asked to play ' + marker + ' but already playing ' + this.currentMarker); + console.log('asked to play ' + marker + ' but already playing ' + this.currentMarker); if (this.usingWebAudio) { @@ -325,9 +327,10 @@ Phaser.Sound.prototype = { this.position = this.markers[marker].start; this.volume = this.markers[marker].volume; this.loop = this.markers[marker].loop; - this.duration = this.markers[marker].duration * 1000; + this.duration = this.markers[marker].duration; + + console.log('Marker Loaded: ', marker, 'start:', this.position, 'end: ', this.duration, 'loop', this.loop); - console.log('marker info loaded', this.loop, this.duration); this._tempMarker = marker; this._tempPosition = this.position; this._tempVolume = this.volume; @@ -335,7 +338,7 @@ Phaser.Sound.prototype = { } else { - console.log('no marker info loaded'); + console.log('no marker info loaded', marker); this.position = position; this.volume = volume; @@ -377,12 +380,14 @@ Phaser.Sound.prototype = { // Useful to cache this somewhere perhaps? if (typeof this._sound.start === 'undefined') { - this._sound.noteGrainOn(0, this.position, this.duration / 1000); + this._sound.noteGrainOn(0, this.position, this.duration); + // this._sound.noteGrainOn(0, this.position, this.duration / 1000); //this._sound.noteOn(0); // the zero is vitally important, crashes iOS6 without it } else { - this._sound.start(0, this.position, this.duration / 1000); + // this._sound.start(0, this.position, this.duration / 1000); + this._sound.start(0, this.position, this.duration); } this.isPlaying = true;