From 4b177e0a9bef1c68397288dd8326ec08bb4c87d2 Mon Sep 17 00:00:00 2001 From: Webeled Date: Mon, 30 Sep 2013 13:26:56 +0100 Subject: [PATCH 1/4] Manual update --- 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, 87 insertions(+), 19 deletions(-) diff --git a/src/animation/Animation.js b/src/animation/Animation.js index 4604a99a..90f456cf 100644 --- a/src/animation/Animation.js +++ b/src/animation/Animation.js @@ -223,7 +223,7 @@ Phaser.Animation.prototype = { { if (this.looped) { - this._frameIndex = this._frameIndex - this._frames.length; + 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 f6e40ea3..9bee583a 100644 --- a/src/animation/AnimationManager.js +++ b/src/animation/AnimationManager.js @@ -305,6 +305,22 @@ 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 86a2b8c6..da190432 100644 --- a/src/core/StateManager.js +++ b/src/core/StateManager.js @@ -235,7 +235,9 @@ Phaser.StateManager.prototype = { this.onShutDownCallback.call(this.callbackContext); } - if (clearWorld) { + if (clearWorld) + { + this.game.tweens.removeAll(); this.game.world.destroy(); diff --git a/src/gameobjects/Button.js b/src/gameobjects/Button.js index 171ed086..ddf0871f 100644 --- a/src/gameobjects/Button.js +++ b/src/gameobjects/Button.js @@ -151,6 +151,7 @@ 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 d10f366a..dbb2337a 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 = x; - this.position.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.alive = true; this.exists = true; this.visible = true; @@ -470,6 +470,25 @@ 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 d8d886f3..c3fb007c 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.emiteX - this.game.rnd.integerInRange(this.left, this.right), this.emiteY - this.game.rnd.integerInRange(this.top, this.bottom)); + particle.reset(this.game.rnd.integerInRange(this.left, this.right), this.game.rnd.integerInRange(this.top, this.bottom)); } else { diff --git a/src/physics/arcade/ArcadePhysics.js b/src/physics/arcade/ArcadePhysics.js index 57eb4b63..1402007a 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 f466cbfb..6a45bc7b 100644 --- a/src/sound/Sound.js +++ b/src/sound/Sound.js @@ -172,6 +172,7 @@ 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; @@ -186,6 +187,26 @@ 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) { @@ -266,19 +287,20 @@ Phaser.Sound.prototype = { position = position || 0; volume = volume || 1; if (typeof loop == 'undefined') { loop = false; } - if (typeof forceRestart == 'undefined') { forceRestart = false; } + if (typeof forceRestart == 'undefined') { forceRestart = true; } - // console.log(this.name + ' play ' + marker + ' position ' + position + ' volume ' + volume + ' loop ' + loop); + console.log(this.name + ' play ' + marker + ' position ' + position + ' volume ' + volume + ' loop ' + loop, 'force', forceRestart); 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) { @@ -305,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; @@ -315,6 +338,8 @@ Phaser.Sound.prototype = { } else { + console.log('no marker info loaded', marker); + this.position = position; this.volume = volume; this.loop = loop; @@ -355,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; diff --git a/src/sound/SoundManager.js b/src/sound/SoundManager.js index 5464b6f6..252b57d6 100644 --- a/src/sound/SoundManager.js +++ b/src/sound/SoundManager.js @@ -293,8 +293,6 @@ 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 e1161377..07fe841d 100644 --- a/src/tween/Tween.js +++ b/src/tween/Tween.js @@ -246,11 +246,15 @@ Phaser.Tween.prototype = { pause: function () { this._paused = true; + this._pausedTime = this.game.time.now; }, resume: function () { + this._paused = false; - this._startTime += this.game.time.pauseDuration; + + this._startTime += (this.game.time.now - this._pausedTime); + }, update: function ( time ) { diff --git a/src/tween/TweenManager.js b/src/tween/TweenManager.js index c6ab3920..e4c0963f 100644 --- a/src/tween/TweenManager.js +++ b/src/tween/TweenManager.js @@ -39,7 +39,8 @@ Phaser.TweenManager.prototype = { */ removeAll: function () { - this._tweens = []; + this._add.length = 0; + this._tweens.length = 0; }, From bdc8edea9dc1e0302acd6b457df883940d887bfa Mon Sep 17 00:00:00 2001 From: Webeled Date: Mon, 30 Sep 2013 17:30:45 +0100 Subject: [PATCH 2/4] Lots of new examples :) Lots of new examples, the wip/examples folder can be destoryed I think --- examples/display/fullscreen.php | 55 ++++++++ examples/display/linkedList.php | 65 +++++++++ .../groups/sub groups and group length.php | 77 +++++++++++ .../groups/swap children inside a group.php | 52 +++++++ examples/input/drag.php | 2 +- examples/input/drop limitation.php | 63 +++++++++ examples/input/game scale.php | 76 +++++++++++ examples/input/keyboard.php | 2 +- examples/input/motion lock - horizontal.php | 54 ++++++++ examples/input/motion lock - vertical.php | 54 ++++++++ examples/input/multi touch.php | 10 +- .../override browser keyboard controls.php | 127 ++++++++++++++++++ examples/misc/net.php | 39 ++++++ examples/physics/Motion.php | 80 +++++++++++ examples/physics/sprite bounds.php | 62 +++++++++ 15 files changed, 807 insertions(+), 11 deletions(-) create mode 100644 examples/display/fullscreen.php create mode 100644 examples/display/linkedList.php create mode 100644 examples/groups/sub groups and group length.php create mode 100644 examples/groups/swap children inside a group.php create mode 100644 examples/input/drop limitation.php create mode 100644 examples/input/game scale.php create mode 100644 examples/input/motion lock - horizontal.php create mode 100644 examples/input/motion lock - vertical.php create mode 100644 examples/input/override browser keyboard controls.php create mode 100644 examples/misc/net.php create mode 100644 examples/physics/Motion.php create mode 100644 examples/physics/sprite bounds.php diff --git a/examples/display/fullscreen.php b/examples/display/fullscreen.php new file mode 100644 index 00000000..966974c8 --- /dev/null +++ b/examples/display/fullscreen.php @@ -0,0 +1,55 @@ + + + + + \ No newline at end of file diff --git a/examples/display/linkedList.php b/examples/display/linkedList.php new file mode 100644 index 00000000..44e0a1f2 --- /dev/null +++ b/examples/display/linkedList.php @@ -0,0 +1,65 @@ + + + + + + diff --git a/examples/groups/sub groups and group length.php b/examples/groups/sub groups and group length.php new file mode 100644 index 00000000..d423dce8 --- /dev/null +++ b/examples/groups/sub groups and group length.php @@ -0,0 +1,77 @@ + + + + + + diff --git a/examples/groups/swap children inside a group.php b/examples/groups/swap children inside a group.php new file mode 100644 index 00000000..d4e9138d --- /dev/null +++ b/examples/groups/swap children inside a group.php @@ -0,0 +1,52 @@ + + + + + + diff --git a/examples/input/drag.php b/examples/input/drag.php index 5b22b440..8e0b42f7 100644 --- a/examples/input/drag.php +++ b/examples/input/drag.php @@ -1,5 +1,5 @@ diff --git a/examples/input/drop limitation.php b/examples/input/drop limitation.php new file mode 100644 index 00000000..a7326688 --- /dev/null +++ b/examples/input/drop limitation.php @@ -0,0 +1,63 @@ + + + + + + diff --git a/examples/input/game scale.php b/examples/input/game scale.php new file mode 100644 index 00000000..2a6c7d32 --- /dev/null +++ b/examples/input/game scale.php @@ -0,0 +1,76 @@ + + + + + diff --git a/examples/input/keyboard.php b/examples/input/keyboard.php index c5a432da..7b9a5def 100644 --- a/examples/input/keyboard.php +++ b/examples/input/keyboard.php @@ -44,7 +44,7 @@ game.add.sprite(900, 170, 'cloud2') .scrollFactor.setTo(0.7, 0.3); - // Create a ufo spirte as player. + // Create a ufo sprite as player. ufo = game.add.sprite(320, 240, 'ufo'); ufo.anchor.setTo(0.5, 0.5); diff --git a/examples/input/motion lock - horizontal.php b/examples/input/motion lock - horizontal.php new file mode 100644 index 00000000..39d4957b --- /dev/null +++ b/examples/input/motion lock - horizontal.php @@ -0,0 +1,54 @@ + + + + + diff --git a/examples/input/motion lock - vertical.php b/examples/input/motion lock - vertical.php new file mode 100644 index 00000000..a67e3a1f --- /dev/null +++ b/examples/input/motion lock - vertical.php @@ -0,0 +1,54 @@ + + + + + diff --git a/examples/input/multi touch.php b/examples/input/multi touch.php index a34ebe10..1ab9ccf3 100644 --- a/examples/input/multi touch.php +++ b/examples/input/multi touch.php @@ -7,13 +7,8 @@ (function () { - var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render }); + var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', {create: create, render: render }); - function preload() { - - // game.load.image('disk', 'assets/sprites/ra_dont_crack_under_pressure.png'); - - } function create() { @@ -21,9 +16,6 @@ } - function update() { - } - function render() { game.debug.renderPointer(game.input.mousePointer); diff --git a/examples/input/override browser keyboard controls.php b/examples/input/override browser keyboard controls.php new file mode 100644 index 00000000..8d2cdb78 --- /dev/null +++ b/examples/input/override browser keyboard controls.php @@ -0,0 +1,127 @@ + + + + + + diff --git a/examples/misc/net.php b/examples/misc/net.php new file mode 100644 index 00000000..35032df4 --- /dev/null +++ b/examples/misc/net.php @@ -0,0 +1,39 @@ + + + + +Reload with query string + + + diff --git a/examples/physics/Motion.php b/examples/physics/Motion.php new file mode 100644 index 00000000..bb9dd509 --- /dev/null +++ b/examples/physics/Motion.php @@ -0,0 +1,80 @@ + + + + + + diff --git a/examples/physics/sprite bounds.php b/examples/physics/sprite bounds.php new file mode 100644 index 00000000..f299b2fb --- /dev/null +++ b/examples/physics/sprite bounds.php @@ -0,0 +1,62 @@ + + + + + + From 933edb203fe540c32c9dee7abaf9fc739d316192 Mon Sep 17 00:00:00 2001 From: Webeled Date: Mon, 30 Sep 2013 19:13:01 +0100 Subject: [PATCH 3/4] Final Commit of the day, Final commit, the wip/examples folder can be removed, --- examples/input/game scale.php | 2 +- examples/loader/loading multiple files.php | 60 ++++++++++++++++++++++ examples/loader/spritesheet loading.php | 54 +++++++++++++++++++ examples/misc/net.php | 1 - examples/misc/random generators.php | 32 ++++++++++++ examples/sprites/outOfBounds.php | 54 +++++++++++++++++++ 6 files changed, 201 insertions(+), 2 deletions(-) create mode 100644 examples/loader/loading multiple files.php create mode 100644 examples/loader/spritesheet loading.php create mode 100644 examples/misc/random generators.php create mode 100644 examples/sprites/outOfBounds.php diff --git a/examples/input/game scale.php b/examples/input/game scale.php index 2a6c7d32..3eea2c62 100644 --- a/examples/input/game scale.php +++ b/examples/input/game scale.php @@ -7,7 +7,7 @@ (function () { - var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create,update:update,render:render}); + var game = new Phaser.Game(320, 240, Phaser.CANVAS, '', { preload: preload, create: create,update:update,render:render}); function preload() { diff --git a/examples/loader/loading multiple files.php b/examples/loader/loading multiple files.php new file mode 100644 index 00000000..82d2f139 --- /dev/null +++ b/examples/loader/loading multiple files.php @@ -0,0 +1,60 @@ + + + + + + + \ No newline at end of file diff --git a/examples/loader/spritesheet loading.php b/examples/loader/spritesheet loading.php new file mode 100644 index 00000000..f7e751b9 --- /dev/null +++ b/examples/loader/spritesheet loading.php @@ -0,0 +1,54 @@ + + + + + + + \ No newline at end of file diff --git a/examples/misc/net.php b/examples/misc/net.php index 35032df4..2425d376 100644 --- a/examples/misc/net.php +++ b/examples/misc/net.php @@ -18,7 +18,6 @@ // Add some values to the query string game.debug.renderText('Query string with new values : '+game.net.updateQueryString('atari', '520'),game.world.centerX-400,80); game.debug.renderText('Query string with new values : '+game.net.updateQueryString('amiga', '1200'),game.world.centerX-400,100); - game.debug.renderText('Query string with new values : '+game.net.updateQueryString('commodore', '64'),game.world.centerX-400,120); console.log('Query String: '+game.net.getQueryString(),game.world.centerX-300,140); console.log('Query String Param: '+game.net.getQueryString('atari'),game.world.centerX-300,160); diff --git a/examples/misc/random generators.php b/examples/misc/random generators.php new file mode 100644 index 00000000..2203d9c3 --- /dev/null +++ b/examples/misc/random generators.php @@ -0,0 +1,32 @@ + + + + + \ No newline at end of file diff --git a/examples/sprites/outOfBounds.php b/examples/sprites/outOfBounds.php new file mode 100644 index 00000000..f07d81d3 --- /dev/null +++ b/examples/sprites/outOfBounds.php @@ -0,0 +1,54 @@ + + + + + \ No newline at end of file From 5afce4bf8ed6d116eda29a44a2b894793164885a Mon Sep 17 00:00:00 2001 From: Webeled Date: Mon, 30 Sep 2013 19:18:33 +0100 Subject: [PATCH 4/4] 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 = []; },