Tween no longer copies all the object properties into the _valuesStart object on creation.

Fixed shadow bug in Debug.text
Fixed tween examples.
This commit is contained in:
photonstorm 2014-03-03 02:40:59 +00:00
parent 76040d303e
commit 6f513042c1
7 changed files with 55 additions and 34 deletions

View file

@ -159,6 +159,7 @@ Updates:
* Pausing the game will now mute audio and resuming will un-mute, unless it was muted via the game (fixes #439)
* ScaleManager has 2 new events: ScaleManager.enterFullScreen and ScaleManager.leaveFullScreen, so you can respond to fullscreen changes directly.
* RandomDataGenerator.integerInRange(min, max) now includes both `min` and `max` within its range (#501)
* Tween no longer copies all the object properties into the `_valuesStart` object on creation.
Bug Fixes:

View file

@ -91,6 +91,7 @@
<script src="../src/input/SinglePad.js"></script>
<script src="../src/input/GamepadButton.js"></script>
<script src="../src/input/InputHandler.js"></script>
<script src="../src/input/Gestures.js"></script>
<script src="../src/gameobjects/Events.js"></script>
<script src="../src/gameobjects/GameObjectCreator.js"></script>

View file

@ -91,6 +91,7 @@
<script src="../src/input/SinglePad.js"></script>
<script src="../src/input/GamepadButton.js"></script>
<script src="../src/input/InputHandler.js"></script>
<script src="../src/input/Gestures.js"></script>
<script src="../src/gameobjects/Events.js"></script>
<script src="../src/gameobjects/GameObjectCreator.js"></script>

View file

@ -31,16 +31,16 @@ function create() {
// Also set the origin to the center since we don't want to
// see the shadow scale to the left top.
shadow.anchor.setTo(0.5, 0.5);
game.add.tween(shadow.scale).to({x: 1.0, y: 1.0}, 2400, Phaser.Easing.Bounce.Out);
game.add.tween(shadow.scale).to({x: 1.0, y: 1.0}, 2400, Phaser.Easing.Bounce.Out, true);
// Add characters on top of shadows.
item = game.add.sprite(190 + 69 * i, -100, 'phaser', i);
item = game.add.sprite(190 + 69 * i, -50, 'phaser', i);
// Set origin to the center to make the rotation look better.
item.anchor.setTo(0.5, 0.5);
// Add a simple bounce tween to each character's position.
tween = game.add.tween(item).to({y: 240}, 2400, Phaser.Easing.Bounce.Out);
tween = game.add.tween(item).to( { y: 245 }, 2400, Phaser.Easing.Bounce.Out, true);
}
}

View file

@ -100,7 +100,9 @@ Phaser.Gestures.prototype = {
delete this._gestures[i];
}
}
this._gestures = this._gestures.filter(function(a){return typeof a !== 'undefined';});
},
/**
@ -112,12 +114,14 @@ Phaser.Gestures.prototype = {
if (this.active && this._pointers.length > 0)
{
var hasPointers = this._pointers.filter(function(p){return p.isDown;}).length > 0;
for (var i = this._gestures.length - 1; i >= 0; --i)
{
if (!this._gestures[i].hasStarted)
{
this._gestures[i].hasStarted = true;
this._gestures[i].gesture.start(this._pointers);
if (this._gestures[i].onGestureStarted != null)
{
this._gestures[i].onGestureStarted();
@ -126,8 +130,11 @@ Phaser.Gestures.prototype = {
else
{
var result = this._gestures[i].gesture.update(this._pointers);
if(result){
if (result)
{
var data = this._gestures[i].gesture.getData();
if (this._gestures[i].onGestureUpdated != null)
{
this._gestures[i].onGestureUpdated(data);
@ -137,6 +144,7 @@ Phaser.Gestures.prototype = {
{
this._gestures[i].gesture.stop(this._pointers);
this._gestures[i].hasStarted = false;
if (this._gestures[i].onGestureStopped != null)
{
this._gestures[i].onGestureStopped();
@ -147,6 +155,7 @@ Phaser.Gestures.prototype = {
this._pointers = this._pointers.filter(function(p){return p.isDown;});
}
},
/**
@ -157,6 +166,7 @@ Phaser.Gestures.prototype = {
_updatePointerState: function (pointer) {
var pointerObject = null;
for (var i = this._pointers.length - 1; i >= 0; --i)
{
if (this._pointers[i].pointer == pointer)
@ -174,6 +184,7 @@ Phaser.Gestures.prototype = {
isUp: false,
isDown: true
}
this._pointers.push(pointerObject);
}
else if (pointerObject != null)
@ -183,6 +194,7 @@ Phaser.Gestures.prototype = {
pointerObject.isUp = pointer.isUp;
}
}
};
Phaser.Gestures.prototype.constructor = Phaser.Gestures;
@ -201,6 +213,7 @@ Phaser.Gestures.Helpers = {
createOrFindPointerData: function(pointerArray, pointer) {
var pointerObject = null;
for (var i = pointerArray.length - 1; i >= 0; --i)
{
if (pointerArray[i].pointer == pointer)
@ -209,16 +222,20 @@ Phaser.Gestures.Helpers = {
break;
}
}
if (pointerObject == null)
{
pointerObject = {
pointer:pointer,
isNew: true
}
pointerArray.push(pointerObject);
}
return pointerObject;
}
};
Phaser.Gesture = {};

View file

@ -158,11 +158,11 @@ Phaser.Tween = function (object, game) {
*/
this.pendingDelete = false;
// Set all starting values present on the target object
for (var field in object)
{
this._valuesStart[field] = parseFloat(object[field], 10);
}
// Set all starting values present on the target object - why? this will copy loads of properties we don't need - commenting out for now
// for (var field in object)
// {
// this._valuesStart[field] = parseFloat(object[field], 10);
// }
/**
* @property {Phaser.Signal} onStart - The onStart event is fired when the Tween begins.
@ -277,7 +277,7 @@ Phaser.Tween.prototype = {
for (var property in this._valuesEnd)
{
// check if an Array was provided as property value
if (this._valuesEnd[property] instanceof Array)
if (Array.isArray(this._valuesEnd[property]))
{
if (this._valuesEnd[property].length === 0)
{
@ -290,7 +290,7 @@ Phaser.Tween.prototype = {
this._valuesStart[property] = this._object[property];
if ((this._valuesStart[property] instanceof Array) === false)
if (!Array.isArray(this._valuesStart[property]))
{
this._valuesStart[property] *= 1.0; // Ensures we're using numbers, not strings
}

View file

@ -581,15 +581,16 @@ Phaser.Utils.Debug.prototype = {
this.start();
this.context.font = font;
this.context.fillStyle = color;
this.context.fillText(text, x, y);
if (this.renderShadow)
{
this.context.fillStyle = 'rgb(0,0,0)';
this.context.fillText(text, this.currentX + 1, this.currentY + 1);
this.context.fillText(text, x + 1, y + 1);
}
this.context.fillStyle = color;
this.context.fillText(text, x, y);
this.stop();
},