Manual update

This commit is contained in:
Webeled
2013-09-30 13:26:56 +01:00
parent 8096dc67f5
commit 4b177e0a9b
11 changed files with 87 additions and 19 deletions
+2 -2
View File
@@ -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;
}
}
+16
View File
@@ -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", {
/**
+3 -1
View File
@@ -235,7 +235,9 @@ Phaser.StateManager.prototype = {
this.onShutDownCallback.call(this.callbackContext);
}
if (clearWorld) {
if (clearWorld)
{
this.game.tweens.removeAll();
this.game.world.destroy();
+1
View File
@@ -151,6 +151,7 @@ Phaser.Button.prototype.onInputOutHandler = function (pointer) {
{
this.onInputOut.dispatch(this, pointer);
}
};
Phaser.Button.prototype.onInputDownHandler = function (pointer) {
+21 -2
View File
@@ -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() {
+1 -1
View File
@@ -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
{
+2 -2
View File
@@ -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;
+34 -7
View File
@@ -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;
-2
View File
@@ -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);
+5 -1
View File
@@ -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 ) {
+2 -1
View File
@@ -39,7 +39,8 @@ Phaser.TweenManager.prototype = {
*/
removeAll: function () {
this._tweens = [];
this._add.length = 0;
this._tweens.length = 0;
},