mirror of
https://github.com/wassname/phaser.git
synced 2026-06-27 16:10:15 +08:00
Added class constructors, fixed Stripshader, added relative Tween example and updated Tween source.
This commit is contained in:
@@ -49,6 +49,7 @@ Significant API changes:
|
||||
* Loader.tileset has a new method signature. Please use the new format: load.tileset(key, url, tileWidth, tileHeight, tileMargin, tileSpacing, rows, columns, total).
|
||||
* TilemapLayers are now created via the Tilemap object itself: map.createLayer(x, y, width, height, tileset, layer, group) and no longer via the GameObjectFactory.
|
||||
* Tilemap.createFromObjects can now turn a bunch of Tiled objects into Sprites in one single call, and copies across all properties as well.
|
||||
* Tween.onStartCallback and onCompleteCallback have been removed to avoid confusion. You should use the onStart, onLoop and onComplete events instead.
|
||||
|
||||
|
||||
New features:
|
||||
@@ -66,6 +67,7 @@ New features:
|
||||
* Group.set will let you deep set a new propery on a single child of the Group.
|
||||
* Stage.display property added. A direct reference to the root Pixi Stage object (very useful for RenderTexture manipulation)
|
||||
* Added Ejecta detection to Device (thanks endel)
|
||||
* Tweens can now work with relative + and - values. You can do: `tween(sprite).to( { x: '+400' })` and it will add 400 to the current sprite.x value, or '-400'.
|
||||
|
||||
|
||||
New Examples:
|
||||
@@ -104,6 +106,7 @@ Updates:
|
||||
* Input doesn't set the cursor to default if it's already set to none.
|
||||
* You can now collide a group against itself, to have all children collide, and bodies won't check against themselves (thanks cocoademon)
|
||||
* RenderTexture.render / renderXY has a new parameter: renderHidden, a boolean which will allow you to render Sprites even if their visible is set to false.
|
||||
* Added in prototype.constructor definitions to every class (thanks darkoverlordofdata)
|
||||
|
||||
|
||||
Bug Fixes:
|
||||
@@ -119,6 +122,8 @@ Bug Fixes:
|
||||
* Tween.onStart is now called when the tween starts AFTER the delay value, if given (thanks stevenbouma)
|
||||
* Sprites that are fixedToCamera can now be input dragged regardless of world position (thanks RafaelOliveira)
|
||||
* RenderTexture now displays correctly in Canvas games.
|
||||
* Canvas.addToDOM is now more robust when applying the overflowHidden style.
|
||||
* Fixed Pixi.StripShader which should stop the weird TileSprite GPU issues some were reporting (thanks GoodboyDigital)
|
||||
|
||||
|
||||
You can view the Change Log for all previous versions at https://github.com/photonstorm/phaser/changelog.md
|
||||
@@ -266,6 +271,7 @@ Versions 1.2 ("Saldaea")
|
||||
|
||||
* Integration with the p2.js physics system.
|
||||
* Enhance the State Management, so you can perform non-destructive State swaps and persistence.
|
||||
* Update to Pixi 1.5 - currently still in dev branch only, but lots of nice internal changes and new features.
|
||||
|
||||
Beyond version 1.2
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -212,7 +212,7 @@ declare module Phaser {
|
||||
add(child: any): any;
|
||||
addAt(child: any, index: number): any;
|
||||
getAt(index: number): any;
|
||||
create(x: number, y: number, key: string, frame: string, exists?: boolean): any;
|
||||
create(x: number, y: number, key: string, frame?: any, exists?: boolean): Phaser.Sprite;
|
||||
swap(child1: any, child2: any): boolean;
|
||||
bringToTop(child: any): any;
|
||||
getIndex(child: any): number;
|
||||
|
||||
@@ -135,7 +135,7 @@ function gameOver () {
|
||||
|
||||
ball.body.velocity.setTo(0, 0);
|
||||
|
||||
introText.content = "Game Over!";
|
||||
introText.content = 'Game Over!';
|
||||
introText.visible = true;
|
||||
|
||||
}
|
||||
@@ -154,7 +154,7 @@ function ballHitBrick (_ball, _brick) {
|
||||
// New level starts
|
||||
score += 1000;
|
||||
scoreText.content = 'score: ' + score;
|
||||
introText = '- Next Level -';
|
||||
introText.content = '- Next Level -';
|
||||
|
||||
// Let's move the ball back to the paddle
|
||||
ballOnPaddle = true;
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.image('phaser', 'assets/sprites/phaser1.png');
|
||||
game.load.spritesheet('arrows', 'assets/sprites/arrows.png', 23, 31);
|
||||
|
||||
}
|
||||
|
||||
var arrowStart;
|
||||
var arrowEnd;
|
||||
var sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = '#2384e7';
|
||||
|
||||
arrowStart = game.add.sprite(100, 100, 'arrows', 0);
|
||||
|
||||
arrowEnd = game.add.sprite(400, 100, 'arrows', 1);
|
||||
|
||||
sprite = game.add.sprite(100, 164, 'phaser');
|
||||
sprite.inputEnabled = true;
|
||||
|
||||
sprite.events.onInputDown.add(move, this);
|
||||
|
||||
}
|
||||
|
||||
function move() {
|
||||
|
||||
if (sprite.x === 100)
|
||||
{
|
||||
// Here you'll notice we are using a relative value for the tween.
|
||||
// You can specify a number as a string with either + or - at the start of it.
|
||||
// When the tween starts it will take the sprites current X value and add +300 to it.
|
||||
|
||||
game.add.tween(sprite).to( { x: '+300' }, 2000, Phaser.Easing.Linear.None, true);
|
||||
}
|
||||
else if (sprite.x === 400)
|
||||
{
|
||||
game.add.tween(sprite).to( { x: '-300' }, 2000, Phaser.Easing.Linear.None, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
if (sprite.x === 100 || sprite.x === 400)
|
||||
{
|
||||
game.debug.renderText('Click sprite to tween', 32, 32);
|
||||
}
|
||||
|
||||
game.debug.renderText('x: ' + arrowStart.x, arrowStart.x, arrowStart.y - 4);
|
||||
game.debug.renderText('x: ' + arrowEnd.x, arrowEnd.x, arrowEnd.y - 4);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.image('phaser', 'assets/sprites/phaser1.png');
|
||||
game.load.spritesheet('arrows', 'assets/sprites/arrows.png', 23, 31);
|
||||
|
||||
}
|
||||
|
||||
var arrowStart;
|
||||
var arrowEnd;
|
||||
var sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = '#2384e7';
|
||||
|
||||
arrowStart = game.add.sprite(100, 100, 'arrows', 0);
|
||||
|
||||
arrowEnd = game.add.sprite(400, 100, 'arrows', 1);
|
||||
|
||||
sprite = game.add.sprite(100, 164, 'phaser');
|
||||
sprite.inputEnabled = true;
|
||||
|
||||
sprite.events.onInputDown.add(move, this);
|
||||
|
||||
}
|
||||
|
||||
function move() {
|
||||
|
||||
if (sprite.x === 100)
|
||||
{
|
||||
// Here you'll notice we are using a relative value for the tween.
|
||||
// You can specify a number as a string with either + or - at the start of it.
|
||||
// When the tween starts it will take the sprites current X value and add +300 to it.
|
||||
|
||||
game.add.tween(sprite).to( { x: '+300' }, 2000, Phaser.Easing.Linear.None, true);
|
||||
}
|
||||
else if (sprite.x === 400)
|
||||
{
|
||||
game.add.tween(sprite).to( { x: '-300' }, 2000, Phaser.Easing.Linear.None, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
if (sprite.x === 100 || sprite.x === 400)
|
||||
{
|
||||
game.debug.renderText('Click sprite to tween', 32, 32);
|
||||
}
|
||||
|
||||
game.debug.renderText('x: ' + arrowStart.x, arrowStart.x, arrowStart.y - 4);
|
||||
game.debug.renderText('x: ' + arrowEnd.x, arrowEnd.x, arrowEnd.y - 4);
|
||||
|
||||
}
|
||||
@@ -328,6 +328,8 @@ Phaser.Animation.prototype = {
|
||||
|
||||
};
|
||||
|
||||
Phaser.Animation.prototype.constructor = Phaser.Animation;
|
||||
|
||||
/**
|
||||
* @name Phaser.Animation#paused
|
||||
* @property {boolean} paused - Gets and sets the paused state of this Animation.
|
||||
|
||||
@@ -311,6 +311,8 @@ Phaser.AnimationManager.prototype = {
|
||||
|
||||
};
|
||||
|
||||
Phaser.AnimationManager.prototype.constructor = Phaser.AnimationManager;
|
||||
|
||||
/**
|
||||
* @name Phaser.AnimationManager#frameData
|
||||
* @property {Phaser.FrameData} frameData - The current animations FrameData.
|
||||
|
||||
@@ -158,3 +158,5 @@ Phaser.Frame.prototype = {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.Frame.prototype.constructor = Phaser.Frame;
|
||||
|
||||
@@ -223,6 +223,8 @@ Phaser.FrameData.prototype = {
|
||||
|
||||
};
|
||||
|
||||
Phaser.FrameData.prototype.constructor = Phaser.FrameData;
|
||||
|
||||
/**
|
||||
* @name Phaser.FrameData#total
|
||||
* @property {number} total - The total number of frames in this FrameData set.
|
||||
|
||||
@@ -322,6 +322,8 @@ Phaser.Camera.prototype = {
|
||||
|
||||
};
|
||||
|
||||
Phaser.Camera.prototype.constructor = Phaser.Camera;
|
||||
|
||||
/**
|
||||
* The Cameras x coordinate. This value is automatically clamped if it falls outside of the World bounds.
|
||||
* @name Phaser.Camera#x
|
||||
|
||||
@@ -124,6 +124,8 @@ Phaser.Filter.prototype = {
|
||||
|
||||
};
|
||||
|
||||
Phaser.Filter.prototype.constructor = Phaser.Filter;
|
||||
|
||||
/**
|
||||
* @name Phaser.Filter#width
|
||||
* @property {number} width - The width (resolution uniform)
|
||||
|
||||
@@ -635,6 +635,8 @@ Phaser.Game.prototype = {
|
||||
|
||||
};
|
||||
|
||||
Phaser.Game.prototype.constructor = Phaser.Game;
|
||||
|
||||
/**
|
||||
* The paused state of the Game. A paused game doesn't update any of its subsystems.
|
||||
* When a game is paused the onPause event is dispatched. When it is resumed the onResume event is dispatched.
|
||||
|
||||
@@ -1495,6 +1495,8 @@ Phaser.Group.prototype = {
|
||||
|
||||
};
|
||||
|
||||
Phaser.Group.prototype.constructor = Phaser.Group;
|
||||
|
||||
/**
|
||||
* @name Phaser.Group#total
|
||||
* @property {number} total - The total number of children in this Group who have a state of exists = true.
|
||||
|
||||
@@ -151,4 +151,6 @@ Phaser.LinkedList.prototype = {
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
Phaser.LinkedList.prototype.constructor = Phaser.LinkedList;
|
||||
|
||||
@@ -119,3 +119,5 @@ Phaser.Plugin.prototype = {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.Plugin.prototype.constructor = Phaser.Plugin;
|
||||
|
||||
@@ -295,3 +295,5 @@ Phaser.PluginManager.prototype = {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.PluginManager.prototype.constructor = Phaser.PluginManager;
|
||||
|
||||
@@ -300,3 +300,5 @@ Phaser.Signal.prototype = {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.Signal.prototype.constructor = Phaser.Signal;
|
||||
|
||||
@@ -160,3 +160,5 @@ Phaser.SignalBinding.prototype = {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.SignalBinding.prototype.constructor = Phaser.SignalBinding;
|
||||
|
||||
@@ -230,6 +230,8 @@ Phaser.Stage.prototype = {
|
||||
|
||||
};
|
||||
|
||||
Phaser.Stage.prototype.constructor = Phaser.Stage;
|
||||
|
||||
/**
|
||||
* @name Phaser.Stage#backgroundColor
|
||||
* @property {number|string} backgroundColor - Gets and sets the background color of the stage. The color can be given as a number: 0xff0000 or a hex string: '#ff0000'
|
||||
|
||||
@@ -167,3 +167,5 @@ Phaser.State.prototype = {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.State.prototype.constructor = Phaser.State;
|
||||
|
||||
@@ -512,3 +512,5 @@ Phaser.StateManager.prototype = {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.StateManager.prototype.constructor = Phaser.StateManager;
|
||||
|
||||
@@ -957,7 +957,9 @@ Phaser.BitmapData.prototype = {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Phaser.BitmapData.prototype.constructor = Phaser.BitmapData;
|
||||
|
||||
// EaselJS Tiny API emulation
|
||||
|
||||
|
||||
@@ -73,4 +73,6 @@ Phaser.Events.prototype = {
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
Phaser.Events.prototype.constructor = Phaser.Events;
|
||||
|
||||
@@ -318,4 +318,6 @@ Phaser.GameObjectFactory.prototype = {
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
Phaser.GameObjectFactory.prototype.constructor = Phaser.GameObjectFactory;
|
||||
|
||||
@@ -195,6 +195,8 @@ Phaser.Circle.prototype = {
|
||||
|
||||
};
|
||||
|
||||
Phaser.Circle.prototype.constructor = Phaser.Circle;
|
||||
|
||||
/**
|
||||
* The largest distance between any two points on the circle. The same as the radius * 2.
|
||||
* @name Phaser.Circle#diameter
|
||||
|
||||
@@ -288,6 +288,8 @@ Phaser.Point.prototype = {
|
||||
|
||||
};
|
||||
|
||||
Phaser.Point.prototype.constructor = Phaser.Point;
|
||||
|
||||
/**
|
||||
* Adds the coordinates of two points together to create a new point.
|
||||
* @method Phaser.Point.add
|
||||
|
||||
@@ -266,6 +266,8 @@ Phaser.Rectangle.prototype = {
|
||||
|
||||
};
|
||||
|
||||
Phaser.Rectangle.prototype.constructor = Phaser.Rectangle;
|
||||
|
||||
/**
|
||||
* @name Phaser.Rectangle#halfWidth
|
||||
* @property {number} halfWidth - Half of the width of the Rectangle.
|
||||
|
||||
@@ -689,6 +689,8 @@ Phaser.Input.prototype = {
|
||||
|
||||
};
|
||||
|
||||
Phaser.Input.prototype.constructor = Phaser.Input;
|
||||
|
||||
/**
|
||||
* The X coordinate of the most recently active pointer. This value takes game scaling into account automatically. See Pointer.screenX/clientX for source values.
|
||||
* @name Phaser.Input#x
|
||||
|
||||
@@ -1106,4 +1106,6 @@ Phaser.InputHandler.prototype = {
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
Phaser.InputHandler.prototype.constructor = Phaser.InputHandler;
|
||||
|
||||
@@ -169,3 +169,5 @@ Phaser.Key.prototype = {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.Key.prototype.constructor = Phaser.Key;
|
||||
|
||||
@@ -395,6 +395,8 @@ Phaser.Keyboard.prototype = {
|
||||
|
||||
};
|
||||
|
||||
Phaser.Keyboard.prototype.constructor = Phaser.Keyboard;
|
||||
|
||||
Phaser.Keyboard.A = "A".charCodeAt(0);
|
||||
Phaser.Keyboard.B = "B".charCodeAt(0);
|
||||
Phaser.Keyboard.C = "C".charCodeAt(0);
|
||||
|
||||
@@ -165,4 +165,6 @@ Phaser.MSPointer.prototype = {
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
Phaser.MSPointer.prototype.constructor = Phaser.MSPointer;
|
||||
|
||||
@@ -327,3 +327,5 @@ Phaser.Mouse.prototype = {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.Mouse.prototype.constructor = Phaser.Mouse;
|
||||
|
||||
@@ -583,6 +583,8 @@ Phaser.Pointer.prototype = {
|
||||
|
||||
};
|
||||
|
||||
Phaser.Pointer.prototype.constructor = Phaser.Pointer;
|
||||
|
||||
/**
|
||||
* How long the Pointer has been depressed on the touchscreen. If not currently down it returns -1.
|
||||
* @name Phaser.Pointer#duration
|
||||
|
||||
+3
-1
@@ -380,4 +380,6 @@ Phaser.Touch.prototype = {
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
Phaser.Touch.prototype.constructor = Phaser.Touch;
|
||||
|
||||
@@ -845,3 +845,5 @@ Phaser.Cache.prototype = {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.Cache.prototype.constructor = Phaser.Cache;
|
||||
|
||||
@@ -1300,3 +1300,5 @@ Phaser.Loader.prototype = {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.Loader.prototype.constructor = Phaser.Loader;
|
||||
|
||||
+3
-3
@@ -688,7 +688,7 @@ Phaser.Math = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* A Linear Interpolation Method, mostly used by Phaser.Tween.
|
||||
* @method Phaser.Math#linearInterpolation
|
||||
* @param {number} v
|
||||
* @param {number} k
|
||||
@@ -715,7 +715,7 @@ Phaser.Math = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* A Bezier Interpolation Method, mostly used by Phaser.Tween.
|
||||
* @method Phaser.Math#bezierInterpolation
|
||||
* @param {number} v
|
||||
* @param {number} k
|
||||
@@ -736,7 +736,7 @@ Phaser.Math = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* A Catmull Rom Interpolation Method, mostly used by Phaser.Tween.
|
||||
* @method Phaser.Math#catmullRomInterpolation
|
||||
* @param {number} v
|
||||
* @param {number} k
|
||||
|
||||
@@ -263,3 +263,5 @@ Phaser.QuadTree.prototype = {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.QuadTree.prototype.constructor = Phaser.QuadTree;
|
||||
|
||||
@@ -245,3 +245,5 @@ Phaser.RandomDataGenerator.prototype = {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.RandomDataGenerator.prototype.constructor = Phaser.RandomDataGenerator;
|
||||
|
||||
@@ -162,3 +162,5 @@ Phaser.Net.prototype = {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.Net.prototype.constructor = Phaser.Net;
|
||||
|
||||
@@ -76,4 +76,6 @@ Phaser.Particles.prototype = {
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
Phaser.Particles.prototype.constructor = Phaser.Particles;
|
||||
|
||||
@@ -1621,3 +1621,5 @@ Phaser.Physics.Arcade.prototype = {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.Physics.Arcade.prototype.constructor = Phaser.Physics.Arcade;
|
||||
|
||||
@@ -626,6 +626,8 @@ Phaser.Physics.Arcade.Body.prototype = {
|
||||
|
||||
};
|
||||
|
||||
Phaser.Physics.Arcade.Body.prototype.constructor = Phaser.Physics.Arcade.Body;
|
||||
|
||||
/**
|
||||
* @name Phaser.Physics.Arcade.Body#bottom
|
||||
* @property {number} bottom - The bottom value of this Body (same as Body.y + Body.height)
|
||||
|
||||
@@ -27,8 +27,8 @@ PIXI.StripShader = function()
|
||||
'attribute float aColor;',
|
||||
'uniform mat3 translationMatrix;',
|
||||
'uniform vec2 projectionVector;',
|
||||
'uniform vec2 offsetVector;',
|
||||
'varying vec2 vTextureCoord;',
|
||||
'varying vec2 offsetVector;',
|
||||
'varying float vColor;',
|
||||
|
||||
'void main(void) {',
|
||||
|
||||
@@ -703,6 +703,8 @@ Phaser.Sound.prototype = {
|
||||
|
||||
};
|
||||
|
||||
Phaser.Sound.prototype.constructor = Phaser.Sound;
|
||||
|
||||
/**
|
||||
* @name Phaser.Sound#isDecoding
|
||||
* @property {boolean} isDecoding - Returns true if the sound file is still decoding.
|
||||
|
||||
@@ -369,6 +369,8 @@ Phaser.SoundManager.prototype = {
|
||||
|
||||
};
|
||||
|
||||
Phaser.SoundManager.prototype.constructor = Phaser.SoundManager;
|
||||
|
||||
/**
|
||||
* @name Phaser.SoundManager#mute
|
||||
* @property {boolean} mute - Gets or sets the muted state of the SoundManager. This effects all sounds in the game.
|
||||
|
||||
@@ -146,7 +146,7 @@ Phaser.Canvas = {
|
||||
* @method Phaser.Canvas.addToDOM
|
||||
* @param {HTMLCanvasElement} canvas - The canvas to set the touch action on.
|
||||
* @param {string|HTMLElement} parent - The DOM element to add the canvas to.
|
||||
* @param {boolean} overflowHidden - If set to true it will add the overflow='hidden' style to the parent DOM element.
|
||||
* @param {boolean} [overflowHidden=true] - If set to true it will add the overflow='hidden' style to the parent DOM element.
|
||||
* @return {HTMLCanvasElement} Returns the source canvas.
|
||||
*/
|
||||
addToDOM: function (canvas, parent, overflowHidden) {
|
||||
@@ -167,11 +167,6 @@ Phaser.Canvas = {
|
||||
// quick test for a HTMLelement
|
||||
target = parent;
|
||||
}
|
||||
|
||||
if (overflowHidden)
|
||||
{
|
||||
target.style.overflow = 'hidden';
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback, covers an invalid ID and a non HTMLelement object
|
||||
@@ -180,6 +175,11 @@ Phaser.Canvas = {
|
||||
target = document.body;
|
||||
}
|
||||
|
||||
if (overflowHidden && target.style)
|
||||
{
|
||||
target.style.overflow = 'hidden';
|
||||
}
|
||||
|
||||
target.appendChild(canvas);
|
||||
|
||||
return canvas;
|
||||
|
||||
@@ -667,3 +667,5 @@ Phaser.Device.prototype = {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.Device.prototype.constructor = Phaser.Device;
|
||||
|
||||
@@ -154,4 +154,6 @@ Phaser.RequestAnimationFrame.prototype = {
|
||||
return (this._isSetTimeOut === false);
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
Phaser.RequestAnimationFrame.prototype.constructor = Phaser.RequestAnimationFrame;
|
||||
|
||||
@@ -734,6 +734,8 @@ Phaser.StageScaleMode.prototype = {
|
||||
|
||||
};
|
||||
|
||||
Phaser.StageScaleMode.prototype.constructor = Phaser.StageScaleMode;
|
||||
|
||||
/**
|
||||
* @name Phaser.StageScaleMode#isFullScreen
|
||||
* @property {boolean} isFullScreen - Returns true if the browser is in full screen mode, otherwise false.
|
||||
|
||||
@@ -204,6 +204,8 @@ Phaser.Tile.prototype = {
|
||||
|
||||
};
|
||||
|
||||
Phaser.Tile.prototype.constructor = Phaser.Tile;
|
||||
|
||||
/**
|
||||
* @name Phaser.Tile#bottom
|
||||
* @property {number} bottom - The sum of the y and height properties.
|
||||
|
||||
@@ -1086,3 +1086,5 @@ Phaser.Tilemap.prototype = {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.Tilemap.prototype.constructor = Phaser.Tilemap;
|
||||
|
||||
@@ -81,7 +81,7 @@ Phaser.Tileset = function (name, firstgid, width, height, margin, spacing, prope
|
||||
*/
|
||||
this.total = 0;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Phaser.Tileset.prototype = {
|
||||
|
||||
@@ -151,4 +151,6 @@ Phaser.Tileset.prototype = {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Phaser.Tileset.prototype.constructor = Phaser.Tileset;
|
||||
|
||||
+3
-1
@@ -235,4 +235,6 @@ Phaser.Time.prototype = {
|
||||
this._started = this.now;
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
Phaser.Time.prototype.constructor = Phaser.Time;
|
||||
|
||||
+4
-2
@@ -43,7 +43,7 @@ Phaser.Timer = function (game) {
|
||||
|
||||
// Need to add custom FPS rate, for now we'll just use seconds
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Phaser.Timer.prototype = {
|
||||
|
||||
@@ -114,4 +114,6 @@ Phaser.Timer.prototype = {
|
||||
return (this.game.time.now - this._started) * 0.001;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Phaser.Timer.prototype.constructor = Phaser.Timer;
|
||||
|
||||
+76
-120
@@ -112,14 +112,7 @@ Phaser.Tween = function (object, game) {
|
||||
this._chainedTweens = [];
|
||||
|
||||
/**
|
||||
* @property {function} _onStartCallback - An onStart callback.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._onStartCallback = null;
|
||||
|
||||
/**
|
||||
* @property {boolean} _onStartCallbackFired - Private onStart flag.
|
||||
* @property {boolean} _onStartCallbackFired - Private flag.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
@@ -131,14 +124,7 @@ Phaser.Tween = function (object, game) {
|
||||
* @default null
|
||||
*/
|
||||
this._onUpdateCallback = null;
|
||||
|
||||
/**
|
||||
* @property {function} _onCompleteCallback - An onComplete callback.
|
||||
* @private
|
||||
* @default null
|
||||
*/
|
||||
this._onCompleteCallback = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {number} _pausedTime - Private pause timer.
|
||||
* @private
|
||||
@@ -196,7 +182,7 @@ Phaser.Tween.prototype = {
|
||||
* @param {boolean} [yoyo=false] - A tween that yoyos will reverse itself when it completes.
|
||||
* @return {Phaser.Tween} This Tween object.
|
||||
*/
|
||||
to: function ( properties, duration, ease, autoStart, delay, repeat, yoyo ) {
|
||||
to: function (properties, duration, ease, autoStart, delay, repeat, yoyo) {
|
||||
|
||||
duration = duration || 1000;
|
||||
ease = ease || null;
|
||||
@@ -236,9 +222,12 @@ Phaser.Tween.prototype = {
|
||||
|
||||
self._yoyo = yoyo;
|
||||
|
||||
if (autoStart) {
|
||||
if (autoStart)
|
||||
{
|
||||
return this.start();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -252,7 +241,8 @@ Phaser.Tween.prototype = {
|
||||
*/
|
||||
start: function () {
|
||||
|
||||
if (this.game === null || this._object === null) {
|
||||
if (this.game === null || this._object === null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -264,29 +254,28 @@ Phaser.Tween.prototype = {
|
||||
|
||||
this._startTime = this.game.time.now + this._delayTime;
|
||||
|
||||
for ( var property in this._valuesEnd ) {
|
||||
|
||||
for (var property in this._valuesEnd)
|
||||
{
|
||||
// check if an Array was provided as property value
|
||||
if ( this._valuesEnd[ property ] instanceof Array ) {
|
||||
|
||||
if ( this._valuesEnd[ property ].length === 0 ) {
|
||||
|
||||
if (this._valuesEnd[property] instanceof Array)
|
||||
{
|
||||
if (this._valuesEnd[property].length === 0)
|
||||
{
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
// create a local copy of the Array with the start value at the front
|
||||
this._valuesEnd[ property ] = [ this._object[ property ] ].concat( this._valuesEnd[ property ] );
|
||||
|
||||
this._valuesEnd[property] = [this._object[property]].concat(this._valuesEnd[property]);
|
||||
}
|
||||
|
||||
this._valuesStart[ property ] = this._object[ property ];
|
||||
this._valuesStart[property] = this._object[property];
|
||||
|
||||
if ( ( this._valuesStart[ property ] instanceof Array ) === false ) {
|
||||
this._valuesStart[ property ] *= 1.0; // Ensures we're using numbers, not strings
|
||||
if ((this._valuesStart[property] instanceof Array) === false)
|
||||
{
|
||||
this._valuesStart[property] *= 1.0; // Ensures we're using numbers, not strings
|
||||
}
|
||||
|
||||
this._valuesStartRepeat[ property ] = this._valuesStart[ property ] || 0;
|
||||
this._valuesStartRepeat[property] = this._valuesStart[property] || 0;
|
||||
|
||||
}
|
||||
|
||||
@@ -317,7 +306,7 @@ Phaser.Tween.prototype = {
|
||||
* @param {number} amount - The amount of the delay in ms.
|
||||
* @return {Phaser.Tween} Itself.
|
||||
*/
|
||||
delay: function ( amount ) {
|
||||
delay: function (amount) {
|
||||
|
||||
this._delayTime = amount;
|
||||
return this;
|
||||
@@ -331,7 +320,7 @@ Phaser.Tween.prototype = {
|
||||
* @param {number} times - How many times to repeat.
|
||||
* @return {Phaser.Tween} Itself.
|
||||
*/
|
||||
repeat: function ( times ) {
|
||||
repeat: function (times) {
|
||||
|
||||
this._repeat = times;
|
||||
return this;
|
||||
@@ -346,7 +335,7 @@ Phaser.Tween.prototype = {
|
||||
* @param {boolean} yoyo - Set to true to yoyo this tween.
|
||||
* @return {Phaser.Tween} Itself.
|
||||
*/
|
||||
yoyo: function( yoyo ) {
|
||||
yoyo: function(yoyo) {
|
||||
|
||||
this._yoyo = yoyo;
|
||||
return this;
|
||||
@@ -360,7 +349,7 @@ Phaser.Tween.prototype = {
|
||||
* @param {function} easing - The easing function this tween will use, i.e. Phaser.Easing.Linear.None.
|
||||
* @return {Phaser.Tween} Itself.
|
||||
*/
|
||||
easing: function ( easing ) {
|
||||
easing: function (easing) {
|
||||
|
||||
this._easingFunction = easing;
|
||||
return this;
|
||||
@@ -369,12 +358,13 @@ Phaser.Tween.prototype = {
|
||||
|
||||
/**
|
||||
* Set interpolation function the tween will use, by default it uses Phaser.Math.linearInterpolation.
|
||||
* Also available: Phaser.Math.bezierInterpolation and Phaser.Math.catmullRomInterpolation.
|
||||
*
|
||||
* @method Phaser.Tween#interpolation
|
||||
* @param {function} interpolation - The interpolation function to use (Phaser.Math.linearInterpolation by default)
|
||||
* @return {Phaser.Tween} Itself.
|
||||
*/
|
||||
interpolation: function ( interpolation ) {
|
||||
interpolation: function (interpolation) {
|
||||
|
||||
this._interpolationFunction = interpolation;
|
||||
return this;
|
||||
@@ -414,20 +404,6 @@ Phaser.Tween.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets a callback to be fired when the tween starts. Note: callback will be called in the context of the global scope.
|
||||
*
|
||||
* @method Phaser.Tween#onStartCallback
|
||||
* @param {function} callback - The callback to invoke on start.
|
||||
* @return {Phaser.Tween} Itself.
|
||||
*/
|
||||
onStartCallback: function ( callback ) {
|
||||
|
||||
this._onStartCallback = callback;
|
||||
return this;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets a callback to be fired each time this tween updates. Note: callback will be called in the context of the global scope.
|
||||
*
|
||||
@@ -435,35 +411,23 @@ Phaser.Tween.prototype = {
|
||||
* @param {function} callback - The callback to invoke each time this tween is updated.
|
||||
* @return {Phaser.Tween} Itself.
|
||||
*/
|
||||
onUpdateCallback: function ( callback ) {
|
||||
onUpdateCallback: function (callback) {
|
||||
|
||||
this._onUpdateCallback = callback;
|
||||
return this;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets a callback to be fired when the tween completes. Note: callback will be called in the context of the global scope.
|
||||
*
|
||||
* @method Phaser.Tween#onCompleteCallback
|
||||
* @param {function} callback - The callback to invoke on completion.
|
||||
* @return {Phaser.Tween} Itself.
|
||||
*/
|
||||
onCompleteCallback: function ( callback ) {
|
||||
|
||||
this._onCompleteCallback = callback;
|
||||
return this;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Pauses the tween.
|
||||
*
|
||||
* @method Phaser.Tween#pause
|
||||
*/
|
||||
pause: function () {
|
||||
|
||||
this._paused = true;
|
||||
this._pausedTime = this.game.time.now;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -472,8 +436,10 @@ Phaser.Tween.prototype = {
|
||||
* @method Phaser.Tween#resume
|
||||
*/
|
||||
resume: function () {
|
||||
|
||||
this._paused = false;
|
||||
this._startTime += (this.game.time.now - this._pausedTime);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -483,7 +449,7 @@ Phaser.Tween.prototype = {
|
||||
* @param {number} time - A timestamp passed in by the TweenManager.
|
||||
* @return {boolean} false if the tween has completed and should be deleted from the manager, otherwise true (still active).
|
||||
*/
|
||||
update: function ( time ) {
|
||||
update: function (time) {
|
||||
|
||||
if (this.pendingDelete)
|
||||
{
|
||||
@@ -505,77 +471,70 @@ Phaser.Tween.prototype = {
|
||||
if (this._onStartCallbackFired === false)
|
||||
{
|
||||
this.onStart.dispatch(this._object);
|
||||
|
||||
if (this._onStartCallback !== null )
|
||||
{
|
||||
this._onStartCallback.call( this._object );
|
||||
}
|
||||
|
||||
this._onStartCallbackFired = true;
|
||||
}
|
||||
|
||||
var elapsed = ( time - this._startTime ) / this._duration;
|
||||
var elapsed = (time - this._startTime) / this._duration;
|
||||
elapsed = elapsed > 1 ? 1 : elapsed;
|
||||
|
||||
var value = this._easingFunction( elapsed );
|
||||
var value = this._easingFunction(elapsed);
|
||||
|
||||
for ( property in this._valuesEnd ) {
|
||||
|
||||
var start = this._valuesStart[ property ] || 0;
|
||||
var end = this._valuesEnd[ property ];
|
||||
|
||||
if ( end instanceof Array ) {
|
||||
|
||||
this._object[ property ] = this._interpolationFunction( end, value );
|
||||
|
||||
} else {
|
||||
for (property in this._valuesEnd)
|
||||
{
|
||||
var start = this._valuesStart[property] || 0;
|
||||
var end = this._valuesEnd[property];
|
||||
|
||||
if (end instanceof Array)
|
||||
{
|
||||
this._object[property] = this._interpolationFunction(end, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Parses relative end values with start as base (e.g.: +10, -3)
|
||||
if ( typeof(end) === "string" ) {
|
||||
if (typeof(end) === 'string')
|
||||
{
|
||||
end = start + parseFloat(end, 10);
|
||||
}
|
||||
|
||||
// protect against non numeric properties.
|
||||
if ( typeof(end) === "number" ) {
|
||||
this._object[ property ] = start + ( end - start ) * value;
|
||||
if (typeof(end) === 'number')
|
||||
{
|
||||
this._object[property] = start + ( end - start ) * value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( this._onUpdateCallback !== null ) {
|
||||
|
||||
this._onUpdateCallback.call( this._object, value );
|
||||
|
||||
if (this._onUpdateCallback !== null)
|
||||
{
|
||||
this._onUpdateCallback.call(this._object, value);
|
||||
}
|
||||
|
||||
if ( elapsed == 1 ) {
|
||||
|
||||
if ( this._repeat > 0 ) {
|
||||
|
||||
if ( isFinite( this._repeat ) ) {
|
||||
if (elapsed == 1)
|
||||
{
|
||||
if (this._repeat > 0)
|
||||
{
|
||||
if (isFinite(this._repeat))
|
||||
{
|
||||
this._repeat--;
|
||||
}
|
||||
|
||||
// reassign starting values, restart by making startTime = now
|
||||
for ( property in this._valuesStartRepeat ) {
|
||||
|
||||
if ( typeof( this._valuesEnd[ property ] ) === "string" )
|
||||
for (property in this._valuesStartRepeat)
|
||||
{
|
||||
if (typeof(this._valuesEnd[property]) === 'string')
|
||||
{
|
||||
this._valuesStartRepeat[ property ] = this._valuesStartRepeat[ property ] + parseFloat(this._valuesEnd[ property ], 10);
|
||||
this._valuesStartRepeat[property] = this._valuesStartRepeat[property] + parseFloat(this._valuesEnd[property], 10);
|
||||
}
|
||||
|
||||
if (this._yoyo)
|
||||
{
|
||||
var tmp = this._valuesStartRepeat[ property ];
|
||||
this._valuesStartRepeat[ property ] = this._valuesEnd[ property ];
|
||||
this._valuesEnd[ property ] = tmp;
|
||||
var tmp = this._valuesStartRepeat[property];
|
||||
this._valuesStartRepeat[property] = this._valuesEnd[property];
|
||||
this._valuesEnd[property] = tmp;
|
||||
this._reversed = !this._reversed;
|
||||
}
|
||||
|
||||
this._valuesStart[ property ] = this._valuesStartRepeat[ property ];
|
||||
|
||||
this._valuesStart[property] = this._valuesStartRepeat[property];
|
||||
}
|
||||
|
||||
this._startTime = time + this._delayTime;
|
||||
@@ -584,23 +543,18 @@ Phaser.Tween.prototype = {
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
this.isRunning = false;
|
||||
this.onComplete.dispatch(this._object);
|
||||
|
||||
if ( this._onCompleteCallback !== null ) {
|
||||
this._onCompleteCallback.call( this._object );
|
||||
}
|
||||
|
||||
for ( var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i ++ ) {
|
||||
|
||||
this._chainedTweens[ i ].start( time );
|
||||
|
||||
for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i ++)
|
||||
{
|
||||
this._chainedTweens[i].start(time);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -610,3 +564,5 @@ Phaser.Tween.prototype = {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.Tween.prototype.constructor = Phaser.Tween;
|
||||
|
||||
@@ -202,4 +202,6 @@ Phaser.TweenManager.prototype = {
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
Phaser.TweenManager.prototype.constructor = Phaser.TweenManager;
|
||||
|
||||
+2
-1
@@ -918,5 +918,6 @@ Phaser.Utils.Debug.prototype = {
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
Phaser.Utils.Debug.prototype.constructor = Phaser.Utils.Debug;
|
||||
|
||||
Reference in New Issue
Block a user