From 5afce4bf8ed6d116eda29a44a2b894793164885a Mon Sep 17 00:00:00 2001 From: Webeled Date: Mon, 30 Sep 2013 19:18:33 +0100 Subject: [PATCH] Revert "Manual update" This reverts commit 4b177e0a9bef1c68397288dd8326ec08bb4c87d2. --- src/animation/Animation.js | 4 +-- src/animation/AnimationManager.js | 16 ----------- src/core/StateManager.js | 4 +-- src/gameobjects/Button.js | 1 - src/gameobjects/Sprite.js | 23 ++-------------- src/particles/arcade/Emitter.js | 2 +- src/physics/arcade/ArcadePhysics.js | 4 +-- src/sound/Sound.js | 41 +++++------------------------ src/sound/SoundManager.js | 2 ++ src/tween/Tween.js | 6 +---- src/tween/TweenManager.js | 3 +-- 11 files changed, 19 insertions(+), 87 deletions(-) diff --git a/src/animation/Animation.js b/src/animation/Animation.js index 90f456cf..4604a99a 100644 --- a/src/animation/Animation.js +++ b/src/animation/Animation.js @@ -223,7 +223,7 @@ Phaser.Animation.prototype = { { if (this.looped) { - this._frameIndex %= this._frames.length; + this._frameIndex = this._frameIndex - this._frames.length; this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); if (this.currentFrame) @@ -401,4 +401,4 @@ Phaser.Animation.generateFrameNames = function (prefix, min, max, suffix, zeroPa return output; -} +} \ No newline at end of file diff --git a/src/animation/AnimationManager.js b/src/animation/AnimationManager.js index 9bee583a..f6e40ea3 100644 --- a/src/animation/AnimationManager.js +++ b/src/animation/AnimationManager.js @@ -305,22 +305,6 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameTotal", { }); -Object.defineProperty(Phaser.AnimationManager.prototype, "paused", { - - get: function () { - - return this.currentAnim.isPaused; - - }, - - set: function (value) { - - this.currentAnim.paused = value; - - } - -}); - Object.defineProperty(Phaser.AnimationManager.prototype, "frame", { /** diff --git a/src/core/StateManager.js b/src/core/StateManager.js index da190432..86a2b8c6 100644 --- a/src/core/StateManager.js +++ b/src/core/StateManager.js @@ -235,9 +235,7 @@ Phaser.StateManager.prototype = { this.onShutDownCallback.call(this.callbackContext); } - if (clearWorld) - { - this.game.tweens.removeAll(); + if (clearWorld) { this.game.world.destroy(); diff --git a/src/gameobjects/Button.js b/src/gameobjects/Button.js index ddf0871f..171ed086 100644 --- a/src/gameobjects/Button.js +++ b/src/gameobjects/Button.js @@ -151,7 +151,6 @@ Phaser.Button.prototype.onInputOutHandler = function (pointer) { { this.onInputOut.dispatch(this, pointer); } - }; Phaser.Button.prototype.onInputDownHandler = function (pointer) { diff --git a/src/gameobjects/Sprite.js b/src/gameobjects/Sprite.js index dbb2337a..d10f366a 100644 --- a/src/gameobjects/Sprite.js +++ b/src/gameobjects/Sprite.js @@ -363,8 +363,8 @@ Phaser.Sprite.prototype.reset = function(x, y) { this.x = x; this.y = y; - this.position.x = this.x - (this.game.world.camera.x * this.scrollFactor.x); - this.position.y = this.y - (this.game.world.camera.y * this.scrollFactor.y); + this.position.x = x; + this.position.y = y; this.alive = true; this.exists = true; this.visible = true; @@ -470,25 +470,6 @@ Phaser.Sprite.prototype.getBounds = function(rect) { } -/** -* Play an animation based on the given key. The animation should previously have been added via sprite.animations.add() -* If the requested animation is already playing this request will be ignored. If you need to reset an already running animation do so directly on the Animation object itself. -* -* @method play -* @param {String} name The name of the animation to be played, e.g. "fire", "walk", "jump". -* @param {Number} [frameRate=null] The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used. -* @param {Boolean} [loop=null] Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used. -* @return {Phaser.Animation} A reference to playing Animation instance. -*/ -Phaser.Sprite.prototype.play = function (name, frameRate, loop) { - - if (this.animations) - { - this.animations.play(name, frameRate, loop); - } - -} - Object.defineProperty(Phaser.Sprite.prototype, 'angle', { get: function() { diff --git a/src/particles/arcade/Emitter.js b/src/particles/arcade/Emitter.js index c3fb007c..d8d886f3 100644 --- a/src/particles/arcade/Emitter.js +++ b/src/particles/arcade/Emitter.js @@ -358,7 +358,7 @@ Phaser.Particles.Arcade.Emitter.prototype.emitParticle = function () { if (this.width > 1 || this.height > 1) { - particle.reset(this.game.rnd.integerInRange(this.left, this.right), this.game.rnd.integerInRange(this.top, this.bottom)); + particle.reset(this.emiteX - this.game.rnd.integerInRange(this.left, this.right), this.emiteY - this.game.rnd.integerInRange(this.top, this.bottom)); } else { diff --git a/src/physics/arcade/ArcadePhysics.js b/src/physics/arcade/ArcadePhysics.js index 1402007a..57eb4b63 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.maxVelocity.x) - body.velocity.x) / 2; + this._velocityDelta = (this.computeVelocity(1, body, body.velocity.x, body.acceleration.x, body.drag.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.maxVelocity.y) - body.velocity.y) / 2; + this._velocityDelta = (this.computeVelocity(2, body, body.velocity.y, body.acceleration.y, body.drag.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 6a45bc7b..f466cbfb 100644 --- a/src/sound/Sound.js +++ b/src/sound/Sound.js @@ -172,7 +172,6 @@ Phaser.Sound.prototype = { // start and stop are in SECONDS.MS (2.5 = 2500ms, 0.5 = 500ms, etc) // volume is between 0 and 1 - /* addMarker: function (name, start, stop, volume, loop) { volume = volume || 1; @@ -187,26 +186,6 @@ Phaser.Sound.prototype = { loop: loop }; - }, - */ - - // start and stop are in SECONDS.MS (2.5 = 2500ms, 0.5 = 500ms, etc) - // volume is between 0 and 1 - addMarker: function (name, start, duration, volume, loop) { - - volume = volume || 1; - if (typeof loop == 'undefined') { loop = false; } - - this.markers[name] = { - name: name, - start: start, - stop: start + duration, - volume: volume, - duration: duration, - durationMS: duration * 1000, - loop: loop - }; - }, removeMarker: function (name) { @@ -287,20 +266,19 @@ Phaser.Sound.prototype = { position = position || 0; volume = volume || 1; if (typeof loop == 'undefined') { loop = false; } - if (typeof forceRestart == 'undefined') { forceRestart = true; } + if (typeof forceRestart == 'undefined') { forceRestart = false; } - console.log(this.name + ' play ' + marker + ' position ' + position + ' volume ' + volume + ' loop ' + loop, 'force', forceRestart); + // console.log(this.name + ' play ' + marker + ' position ' + position + ' volume ' + volume + ' loop ' + loop); 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) { @@ -327,10 +305,9 @@ 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; - - console.log('Marker Loaded: ', marker, 'start:', this.position, 'end: ', this.duration, 'loop', this.loop); + this.duration = this.markers[marker].duration * 1000; + // console.log('marker info loaded', this.loop, this.duration); this._tempMarker = marker; this._tempPosition = this.position; this._tempVolume = this.volume; @@ -338,8 +315,6 @@ Phaser.Sound.prototype = { } else { - console.log('no marker info loaded', marker); - this.position = position; this.volume = volume; this.loop = loop; @@ -380,14 +355,12 @@ Phaser.Sound.prototype = { // Useful to cache this somewhere perhaps? if (typeof this._sound.start === 'undefined') { - this._sound.noteGrainOn(0, this.position, this.duration); - // this._sound.noteGrainOn(0, this.position, this.duration / 1000); + 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); + this._sound.start(0, this.position, this.duration / 1000); } this.isPlaying = true; diff --git a/src/sound/SoundManager.js b/src/sound/SoundManager.js index 252b57d6..5464b6f6 100644 --- a/src/sound/SoundManager.js +++ b/src/sound/SoundManager.js @@ -293,6 +293,8 @@ Phaser.SoundManager.prototype = { volume = volume || 1; if (typeof loop == 'undefined') { loop = false; } + + var sound = new Phaser.Sound(this.game, key, volume, loop); this._sounds.push(sound); diff --git a/src/tween/Tween.js b/src/tween/Tween.js index 07fe841d..e1161377 100644 --- a/src/tween/Tween.js +++ b/src/tween/Tween.js @@ -246,15 +246,11 @@ Phaser.Tween.prototype = { pause: function () { this._paused = true; - this._pausedTime = this.game.time.now; }, resume: function () { - this._paused = false; - - this._startTime += (this.game.time.now - this._pausedTime); - + this._startTime += this.game.time.pauseDuration; }, update: function ( time ) { diff --git a/src/tween/TweenManager.js b/src/tween/TweenManager.js index e4c0963f..c6ab3920 100644 --- a/src/tween/TweenManager.js +++ b/src/tween/TweenManager.js @@ -39,8 +39,7 @@ Phaser.TweenManager.prototype = { */ removeAll: function () { - this._add.length = 0; - this._tweens.length = 0; + this._tweens = []; },