mirror of
https://github.com/wassname/phaser.git
synced 2026-07-02 17:00:42 +08:00
Adding docs.
This commit is contained in:
@@ -1,37 +1,98 @@
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
* @module Phaser.BitmapText
|
||||
*/
|
||||
|
||||
/**
|
||||
* An Animation instance contains a single animation and the controls to play it.
|
||||
* It is created by the AnimationManager, consists of Animation.Frame objects and belongs to a single Game Object such as a Sprite.
|
||||
*
|
||||
* @class Phaser.BitmapText
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
* @param {number} x - X position of Description.
|
||||
* @param {number} y - Y position of Description.
|
||||
* @param {string} text - Description.
|
||||
* @param {string} style - Description.
|
||||
*/
|
||||
Phaser.BitmapText = function (game, x, y, text, style) {
|
||||
|
||||
x = x || 0;
|
||||
y = y || 0;
|
||||
|
||||
text = text || '';
|
||||
style = style || '';
|
||||
|
||||
// If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all
|
||||
/**
|
||||
* @property {bool} exists - If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all.
|
||||
* @default
|
||||
*/
|
||||
this.exists = true;
|
||||
|
||||
// This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering
|
||||
/**
|
||||
* @property {bool} alive - This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering.
|
||||
* @default
|
||||
*/
|
||||
this.alive = true;
|
||||
|
||||
/**
|
||||
* @property {Description} group - Description.
|
||||
* @default
|
||||
*/
|
||||
this.group = null;
|
||||
|
||||
/**
|
||||
* @property {string} name - Description.
|
||||
* @default
|
||||
*/
|
||||
this.name = '';
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - A reference to the currently running Game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
PIXI.BitmapText.call(this, text, style);
|
||||
|
||||
/**
|
||||
* @property {Description} type - Description.
|
||||
*/
|
||||
this.type = Phaser.BITMAPTEXT;
|
||||
|
||||
/**
|
||||
* @property {number} position.x - Description.
|
||||
*/
|
||||
this.position.x = x;
|
||||
|
||||
/**
|
||||
* @property {number} position.y - Description.
|
||||
*/
|
||||
this.position.y = y;
|
||||
|
||||
// Replaces the PIXI.Point with a slightly more flexible one
|
||||
/**
|
||||
* @property {Phaser.Point} anchor - Description.
|
||||
*/
|
||||
this.anchor = new Phaser.Point();
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} scale - Description.
|
||||
*/
|
||||
this.scale = new Phaser.Point(1, 1);
|
||||
|
||||
// Influence of camera movement upon the position
|
||||
/**
|
||||
* @property {Phaser.Point} scrollFactor - Description.
|
||||
*/
|
||||
this.scrollFactor = new Phaser.Point(1, 1);
|
||||
|
||||
// A mini cache for storing all of the calculated values
|
||||
/**
|
||||
* @property {function} _cache - Description.
|
||||
* @private
|
||||
*/
|
||||
this._cache = {
|
||||
|
||||
dirty: false,
|
||||
@@ -50,6 +111,10 @@ Phaser.BitmapText = function (game, x, y, text, style) {
|
||||
this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x);
|
||||
this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y);
|
||||
|
||||
/**
|
||||
* @property {bool} renderable - Description.
|
||||
* @private
|
||||
*/
|
||||
this.renderable = true;
|
||||
|
||||
};
|
||||
@@ -59,8 +124,9 @@ Phaser.BitmapText.prototype = Object.create(PIXI.BitmapText.prototype);
|
||||
Phaser.BitmapText.prototype.constructor = Phaser.BitmapText;
|
||||
|
||||
/**
|
||||
* Automatically called by World.update
|
||||
*/
|
||||
* Automatically called by World.update
|
||||
* @method Phaser.BitmapText.prototype.update
|
||||
*/
|
||||
Phaser.BitmapText.prototype.update = function() {
|
||||
|
||||
if (!this.exists)
|
||||
@@ -85,6 +151,13 @@ Phaser.BitmapText.prototype.update = function() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get
|
||||
* @returns {Description}
|
||||
*//**
|
||||
* Set
|
||||
* @param {Description} value - Description
|
||||
*/
|
||||
Object.defineProperty(Phaser.BitmapText.prototype, 'angle', {
|
||||
|
||||
get: function() {
|
||||
@@ -97,6 +170,13 @@ Object.defineProperty(Phaser.BitmapText.prototype, 'angle', {
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Get
|
||||
* @returns {Description}
|
||||
*//**
|
||||
* Set
|
||||
* @param {Description} value - Description
|
||||
*/
|
||||
Object.defineProperty(Phaser.BitmapText.prototype, 'x', {
|
||||
|
||||
get: function() {
|
||||
@@ -109,6 +189,13 @@ Object.defineProperty(Phaser.BitmapText.prototype, 'x', {
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Get
|
||||
* @returns {Description}
|
||||
*//**
|
||||
* Set
|
||||
* @param {Description} value - Description
|
||||
*/
|
||||
Object.defineProperty(Phaser.BitmapText.prototype, 'y', {
|
||||
|
||||
get: function() {
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
* @module Phaser.Button
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Create a new <code>Button</code> object.
|
||||
* @class Button
|
||||
* @class Phaser.Button
|
||||
* @constructor
|
||||
*
|
||||
* @param {Phaser.Game} game Current game instance.
|
||||
@@ -22,7 +23,6 @@
|
||||
*/
|
||||
Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame) {
|
||||
|
||||
|
||||
x = x || 0;
|
||||
y = y || 0;
|
||||
key = key || null;
|
||||
@@ -31,21 +31,86 @@ Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame,
|
||||
|
||||
Phaser.Sprite.call(this, game, x, y, key, outFrame);
|
||||
|
||||
/**
|
||||
* @property {Description} type - Description.
|
||||
*/
|
||||
this.type = Phaser.BUTTON;
|
||||
|
||||
/**
|
||||
* @property {Description} _onOverFrameName - Description.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._onOverFrameName = null;
|
||||
|
||||
/**
|
||||
* @property {Description} _onOutFrameName - Description.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._onOutFrameName = null;
|
||||
|
||||
/**
|
||||
* @property {Description} _onDownFrameName - Description.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._onDownFrameName = null;
|
||||
|
||||
/**
|
||||
* @property {Description} _onUpFrameName - Description.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._onUpFrameName = null;
|
||||
|
||||
/**
|
||||
* @property {Description} _onOverFrameID - Description.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._onOverFrameID = null;
|
||||
|
||||
/**
|
||||
* @property {Description} _onOutFrameID - Description.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._onOutFrameID = null;
|
||||
|
||||
/**
|
||||
* @property {Description} _onDownFrameID - Description.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._onDownFrameID = null;
|
||||
|
||||
/**
|
||||
* @property {Description} _onUpFrameID - Description.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._onUpFrameID = null;
|
||||
|
||||
// These are the signals the game will subscribe to
|
||||
/**
|
||||
* @property {Phaser.Signal} onInputOver - Description.
|
||||
*/
|
||||
this.onInputOver = new Phaser.Signal;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Signal} onInputOut - Description.
|
||||
*/
|
||||
this.onInputOut = new Phaser.Signal;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Signal} onInputDown - Description.
|
||||
*/
|
||||
this.onInputDown = new Phaser.Signal;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Signal} onInputUp - Description.
|
||||
*/
|
||||
this.onInputUp = new Phaser.Signal;
|
||||
|
||||
this.setFrames(overFrame, outFrame, downFrame);
|
||||
@@ -70,12 +135,12 @@ Phaser.Button.prototype.constructor = Phaser.Button;
|
||||
|
||||
/**
|
||||
* Used to manually set the frames that will be used for the different states of the button
|
||||
* exactly like setting them in the constructor
|
||||
* exactly like setting them in the constructor.
|
||||
*
|
||||
* @method setFrames
|
||||
* @param {string|number} [overFrame] This is the frame or frameName that will be set when this button is in an over state. Give either a number to use a frame ID or a string for a frame name.
|
||||
* @param {string|number} [outFrame] This is the frame or frameName that will be set when this button is in an out state. Give either a number to use a frame ID or a string for a frame name.
|
||||
* @param {string|number} [downFrame] This is the frame or frameName that will be set when this button is in a down state. Give either a number to use a frame ID or a string for a frame name.
|
||||
* @method Phaser.Button.prototype.setFrames
|
||||
* @param {string|number} [overFrame] - This is the frame or frameName that will be set when this button is in an over state. Give either a number to use a frame ID or a string for a frame name.
|
||||
* @param {string|number} [outFrame] - This is the frame or frameName that will be set when this button is in an out state. Give either a number to use a frame ID or a string for a frame name.
|
||||
* @param {string|number} [downFrame] - This is the frame or frameName that will be set when this button is in a down state. Give either a number to use a frame ID or a string for a frame name.
|
||||
*/
|
||||
Phaser.Button.prototype.setFrames = function (overFrame, outFrame, downFrame) {
|
||||
|
||||
@@ -149,6 +214,12 @@ Phaser.Button.prototype.setFrames = function (overFrame, outFrame, downFrame) {
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*
|
||||
* @method Phaser.Button.prototype.onInputOverHandler
|
||||
* @param {Description} pointer - Description.
|
||||
*/
|
||||
Phaser.Button.prototype.onInputOverHandler = function (pointer) {
|
||||
|
||||
if (this._onOverFrameName != null)
|
||||
@@ -166,6 +237,12 @@ Phaser.Button.prototype.onInputOverHandler = function (pointer) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*
|
||||
* @method Phaser.Button.prototype.onInputOutHandler
|
||||
* @param {Description} pointer - Description.
|
||||
*/
|
||||
Phaser.Button.prototype.onInputOutHandler = function (pointer) {
|
||||
|
||||
if (this._onOutFrameName != null)
|
||||
@@ -181,9 +258,14 @@ Phaser.Button.prototype.onInputOutHandler = function (pointer) {
|
||||
{
|
||||
this.onInputOut.dispatch(this, pointer);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*
|
||||
* @method Phaser.Button.prototype.onInputDownHandler
|
||||
* @param {Description} pointer - Description.
|
||||
*/
|
||||
Phaser.Button.prototype.onInputDownHandler = function (pointer) {
|
||||
|
||||
if (this._onDownFrameName != null)
|
||||
@@ -201,6 +283,12 @@ Phaser.Button.prototype.onInputDownHandler = function (pointer) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*
|
||||
* @method Phaser.Button.prototype.onInputUpHandler
|
||||
* @param {Description} pointer - Description.
|
||||
*/
|
||||
Phaser.Button.prototype.onInputUpHandler = function (pointer) {
|
||||
|
||||
if (this._onUpFrameName != null)
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
* @module Phaser.Events
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* The Events component is a collection of events fired by the parent game object and its components.
|
||||
* @param parent The game object using this Input component
|
||||
*
|
||||
* @class Phaser.Events
|
||||
* @constructor
|
||||
*
|
||||
* @param {Phaser.Sprite} sprite - A reference to Description.
|
||||
*/
|
||||
Phaser.Events = function (sprite) {
|
||||
|
||||
|
||||
@@ -1,15 +1,51 @@
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
* @module Phaser.GameObjectFactory
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*
|
||||
* @class Phaser.GameObjectFactory
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
*/
|
||||
Phaser.GameObjectFactory = function (game) {
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - A reference to the currently running Game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* @property {Phaser.World} world - A reference to the game world.
|
||||
*/
|
||||
this.world = this.game.world;
|
||||
|
||||
};
|
||||
|
||||
Phaser.GameObjectFactory.prototype = {
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - A reference to the currently running Game.
|
||||
* @default
|
||||
*/
|
||||
game: null,
|
||||
|
||||
/**
|
||||
* @property {Phaser.World} world - A reference to the game world.
|
||||
* @default
|
||||
*/
|
||||
world: null,
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* @method existing.
|
||||
* @param {object} - Description.
|
||||
* @return {bool} Description.
|
||||
*/
|
||||
existing: function (object) {
|
||||
|
||||
return this.world.group.add(object);
|
||||
@@ -19,11 +55,12 @@ Phaser.GameObjectFactory.prototype = {
|
||||
/**
|
||||
* Create a new Sprite with specific position and sprite sheet key.
|
||||
*
|
||||
* @param x {number} X position of the new sprite.
|
||||
* @param y {number} Y position of the new sprite.
|
||||
* @param [key] {string|RenderTexture} The image key as defined in the Game.Cache to use as the texture for this sprite OR a RenderTexture
|
||||
* @param [frame] {string|number} If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name.
|
||||
* @returns {Sprite} The newly created sprite object.
|
||||
* @method sprite
|
||||
* @param {number} x - X position of the new sprite.
|
||||
* @param {number} y - Y position of the new sprite.
|
||||
* @param {string|RenderTexture} [key] - The image key as defined in the Game.Cache to use as the texture for this sprite OR a RenderTexture.
|
||||
* @param {string|number} [frame] - If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name.
|
||||
* @returns {Description} Description.
|
||||
*/
|
||||
sprite: function (x, y, key, frame) {
|
||||
|
||||
@@ -34,11 +71,12 @@ Phaser.GameObjectFactory.prototype = {
|
||||
/**
|
||||
* Create a new Sprite with specific position and sprite sheet key that will automatically be added as a child of the given parent.
|
||||
*
|
||||
* @param x {number} X position of the new sprite.
|
||||
* @param y {number} Y position of the new sprite.
|
||||
* @param [key] {string|RenderTexture} The image key as defined in the Game.Cache to use as the texture for this sprite OR a RenderTexture
|
||||
* @param [frame] {string|number} If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name.
|
||||
* @returns {Sprite} The newly created sprite object.
|
||||
* @method child
|
||||
* @param {number} x - X position of the new sprite.
|
||||
* @param {number} y - Y position of the new sprite.
|
||||
* @param {string|RenderTexture} [key] - The image key as defined in the Game.Cache to use as the texture for this sprite OR a RenderTexture.
|
||||
* @param {string|number} [frame] - If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name.
|
||||
* @returns {Description} Description.
|
||||
*/
|
||||
child: function (parent, x, y, key, frame) {
|
||||
|
||||
@@ -51,8 +89,9 @@ Phaser.GameObjectFactory.prototype = {
|
||||
/**
|
||||
* Create a tween object for a specific object. The object can be any JavaScript object or Phaser object such as Sprite.
|
||||
*
|
||||
* @param obj {object} Object the tween will be run on.
|
||||
* @return {Phaser.Tween} The newly created tween object.
|
||||
* @method tween
|
||||
* @param {object} obj - Object the tween will be run on.
|
||||
* @return {Description} Description.
|
||||
*/
|
||||
tween: function (obj) {
|
||||
|
||||
@@ -60,60 +99,159 @@ Phaser.GameObjectFactory.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*
|
||||
* @method group
|
||||
* @param {Description} parent - Description.
|
||||
* @param {Description} name - Description.
|
||||
* @return {Description} Description.
|
||||
*/
|
||||
group: function (parent, name) {
|
||||
|
||||
return new Phaser.Group(this.game, parent, name);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*
|
||||
* @method audio
|
||||
* @param {Description} key - Description.
|
||||
* @param {Description} volume - Description.
|
||||
* @param {Description} loop - Description.
|
||||
* @return {Description} Description.
|
||||
*/
|
||||
audio: function (key, volume, loop) {
|
||||
|
||||
return this.game.sound.add(key, volume, loop);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*
|
||||
* @method tileSprite
|
||||
* @param {Description} x - Description.
|
||||
* @param {Description} y - Description.
|
||||
* @param {Description} width - Description.
|
||||
* @param {Description} height - Description.
|
||||
* @param {Description} key - Description.
|
||||
* @param {Description} frame - Description.
|
||||
* @return {Description} Description.
|
||||
*/
|
||||
tileSprite: function (x, y, width, height, key, frame) {
|
||||
|
||||
return this.world.group.add(new Phaser.TileSprite(this.game, x, y, width, height, key, frame));
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*
|
||||
* @method text
|
||||
* @param {Description} x - Description.
|
||||
* @param {Description} y - Description.
|
||||
* @param {Description} text - Description.
|
||||
* @param {Description} style - Description.
|
||||
*/
|
||||
text: function (x, y, text, style) {
|
||||
|
||||
return this.world.group.add(new Phaser.Text(this.game, x, y, text, style));
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*
|
||||
* @method button
|
||||
* @param {Description} x - Description.
|
||||
* @param {Description} y - Description.
|
||||
* @param {Description} callback - Description.
|
||||
* @param {Description} callbackContext - Description.
|
||||
* @param {Description} overFrame - Description.
|
||||
* @param {Description} outFrame - Description.
|
||||
* @param {Description} downFrame - Description.
|
||||
* @return {Description} Description.
|
||||
*/
|
||||
button: function (x, y, key, callback, callbackContext, overFrame, outFrame, downFrame) {
|
||||
|
||||
return this.world.group.add(new Phaser.Button(this.game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame));
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*
|
||||
* @method graphics
|
||||
* @param {Description} x - Description.
|
||||
* @param {Description} y - Description.
|
||||
* @return {Description} Description.
|
||||
*/
|
||||
graphics: function (x, y) {
|
||||
|
||||
return this.world.group.add(new Phaser.Graphics(this.game, x, y));
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*
|
||||
* @method emitter
|
||||
* @param {Description} x - Description.
|
||||
* @param {Description} y - Description.
|
||||
* @param {Description} maxParticles - Description.
|
||||
* @return {Description} Description.
|
||||
*/
|
||||
emitter: function (x, y, maxParticles) {
|
||||
|
||||
return this.game.particles.add(new Phaser.Particles.Arcade.Emitter(this.game, x, y, maxParticles));
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*
|
||||
* @method bitmapText
|
||||
* @param {Description} x - Description.
|
||||
* @param {Description} y - Description.
|
||||
* @param {Description} text - Description.
|
||||
* @param {Description} style - Description.
|
||||
* @return {Description} Description.
|
||||
*/
|
||||
bitmapText: function (x, y, text, style) {
|
||||
|
||||
return this.world.group.add(new Phaser.BitmapText(this.game, x, y, text, style));
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*
|
||||
* @method tilemap
|
||||
* @param {Description} x - Description.
|
||||
* @param {Description} y - Description.
|
||||
* @param {Description} key - Description.
|
||||
* @param {Description} resizeWorld - Description.
|
||||
* @param {Description} tileWidth - Description.
|
||||
* @param {Description} tileHeight - Description.
|
||||
* @return {Description} Description.
|
||||
*/
|
||||
tilemap: function (x, y, key, resizeWorld, tileWidth, tileHeight) {
|
||||
|
||||
return this.world.group.add(new Phaser.Tilemap(this.game, key, x, y, resizeWorld, tileWidth, tileHeight));
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*
|
||||
* @method renderTexture
|
||||
* @param {Description} key - Description.
|
||||
* @param {Description} width - Description.
|
||||
* @param {Description} height - Description.
|
||||
* @return {Description} Description.
|
||||
*/
|
||||
renderTexture: function (key, width, height) {
|
||||
|
||||
var texture = new Phaser.RenderTexture(this.game, key, width, height);
|
||||
|
||||
@@ -1,9 +1,27 @@
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
* @module Phaser.Graphics
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*
|
||||
* @class Phaser.Graphics
|
||||
* @constructor
|
||||
*
|
||||
* @param {Phaser.Game} game Current game instance.
|
||||
* @param {number} [x] X position of Description.
|
||||
* @param {number} [y] Y position of Description.
|
||||
*/
|
||||
Phaser.Graphics = function (game, x, y) {
|
||||
|
||||
PIXI.Graphics.call(this);
|
||||
|
||||
Phaser.Sprite.call(this, game, x, y);
|
||||
|
||||
/**
|
||||
* @property {Description} type - Description.
|
||||
*/
|
||||
this.type = Phaser.GRAPHICS;
|
||||
|
||||
};
|
||||
|
||||
@@ -1,20 +1,58 @@
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
* @module Phaser.RenderTexture
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of constructor.
|
||||
* @class Phaser.RenderTexture
|
||||
* @classdesc Description of class.
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - Current game instance.
|
||||
* @param {string} key - Description.
|
||||
* @param {number} width - Description.
|
||||
* @param {number} height - Description.
|
||||
*/
|
||||
Phaser.RenderTexture = function (game, key, width, height) {
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - A reference to the currently running game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* @property {Description} name - Description.
|
||||
*/
|
||||
this.name = key;
|
||||
|
||||
PIXI.EventTarget.call( this );
|
||||
|
||||
/**
|
||||
* @property {number} width - Description.
|
||||
*/
|
||||
this.width = width || 100;
|
||||
|
||||
/**
|
||||
* @property {number} height - Description.
|
||||
*/
|
||||
this.height = height || 100;
|
||||
|
||||
// I know this has a typo in it, but it's because the PIXI.RenderTexture does and we need to pair-up with it
|
||||
// once they update pixi to fix the typo, we'll fix it here too :)
|
||||
/** I know this has a typo in it, but it's because the PIXI.RenderTexture does and we need to pair-up with it
|
||||
* once they update pixi to fix the typo, we'll fix it here too :)
|
||||
* @property {Description} indetityMatrix - Description.
|
||||
*/
|
||||
this.indetityMatrix = PIXI.mat3.create();
|
||||
|
||||
/**
|
||||
* @property {Description} frame - Description.
|
||||
*/
|
||||
this.frame = new PIXI.Rectangle(0, 0, this.width, this.height);
|
||||
|
||||
/**
|
||||
* @property {Description} type - Description.
|
||||
*/
|
||||
this.type = Phaser.RENDERTEXTURE;
|
||||
|
||||
if (PIXI.gl)
|
||||
|
||||
+252
-74
@@ -1,48 +1,94 @@
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
* @module Phaser.Sprite
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create a new <code>Sprite</code>.
|
||||
* @class Phaser.Sprite
|
||||
* @classdesc Description of class.
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - Current game instance.
|
||||
* @param {Description} x - Description.
|
||||
* @param {Description} y - Description.
|
||||
* @param {string} key - Description.
|
||||
* @param {Description} frame - Description.
|
||||
*/
|
||||
Phaser.Sprite = function (game, x, y, key, frame) {
|
||||
|
||||
x = x || 0;
|
||||
y = y || 0;
|
||||
key = key || null;
|
||||
frame = frame || null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - A reference to the currently running Game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
// If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all
|
||||
|
||||
/**
|
||||
* @property {bool} exists - If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all.
|
||||
* @default
|
||||
*/
|
||||
this.exists = true;
|
||||
|
||||
// This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering
|
||||
/**
|
||||
* @property {bool} alive - This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering.
|
||||
* @default
|
||||
*/
|
||||
this.alive = true;
|
||||
|
||||
/**
|
||||
* @property {Description} group - Description.
|
||||
* @default
|
||||
*/
|
||||
this.group = null;
|
||||
|
||||
/**
|
||||
* @property {string} name - The user defined name given to this Sprite.
|
||||
* @default
|
||||
*/
|
||||
this.name = '';
|
||||
|
||||
/**
|
||||
* @property {Description} type - Description.
|
||||
*/
|
||||
this.type = Phaser.SPRITE;
|
||||
|
||||
/**
|
||||
* @property {number} renderOrderID - Description.
|
||||
* @default
|
||||
*/
|
||||
this.renderOrderID = -1;
|
||||
|
||||
// If you would like the Sprite to have a lifespan once 'born' you can set this to a positive value. Handy for particles, bullets, etc.
|
||||
// The lifespan is decremented by game.time.elapsed each update, once it reaches zero the kill() function is called.
|
||||
/**
|
||||
* If you would like the Sprite to have a lifespan once 'born' you can set this to a positive value. Handy for particles, bullets, etc.
|
||||
* The lifespan is decremented by game.time.elapsed each update, once it reaches zero the kill() function is called.
|
||||
* @property {number} lifespan
|
||||
* @default
|
||||
*/
|
||||
this.lifespan = 0;
|
||||
|
||||
/**
|
||||
* The Signals you can subscribe to that are dispatched when certain things happen on this Sprite or its components
|
||||
* @type Events
|
||||
*/
|
||||
* @property {Events} events - The Signals you can subscribe to that are dispatched when certain things happen on this Sprite or its components
|
||||
*/
|
||||
this.events = new Phaser.Events(this);
|
||||
|
||||
/**
|
||||
* This manages animations of the sprite. You can modify animations through it. (see AnimationManager)
|
||||
* @type AnimationManager
|
||||
*/
|
||||
* @property {AnimationManager} animations - This manages animations of the sprite. You can modify animations through it. (see AnimationManager)
|
||||
*/
|
||||
this.animations = new Phaser.AnimationManager(this);
|
||||
|
||||
/**
|
||||
* The Input Handler Component
|
||||
* @type InputHandler
|
||||
*/
|
||||
* @property {InputHandler} input - The Input Handler Component.
|
||||
*/
|
||||
this.input = new Phaser.InputHandler(this);
|
||||
|
||||
/**
|
||||
* @property {Description} key - Description.
|
||||
*/
|
||||
this.key = key;
|
||||
|
||||
if (key instanceof Phaser.RenderTexture)
|
||||
@@ -83,46 +129,70 @@ Phaser.Sprite = function (game, x, y, key, frame) {
|
||||
}
|
||||
|
||||
/**
|
||||
* The anchor sets the origin point of the texture.
|
||||
* The default is 0,0 this means the textures origin is the top left
|
||||
* Setting than anchor to 0.5,0.5 means the textures origin is centered
|
||||
* Setting the anchor to 1,1 would mean the textures origin points will be the bottom right
|
||||
*
|
||||
* @property anchor
|
||||
* @type Point
|
||||
*/
|
||||
* The anchor sets the origin point of the texture.
|
||||
* The default is 0,0 this means the textures origin is the top left
|
||||
* Setting than anchor to 0.5,0.5 means the textures origin is centered
|
||||
* Setting the anchor to 1,1 would mean the textures origin points will be the bottom right
|
||||
*
|
||||
* @property {Phaser.Point} anchor
|
||||
*/
|
||||
this.anchor = new Phaser.Point();
|
||||
|
||||
/**
|
||||
* @property {Description} _cropUUID - Description.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._cropUUID = null;
|
||||
|
||||
/**
|
||||
* @property {Description} _cropUUID - Description.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._cropRect = null;
|
||||
|
||||
/**
|
||||
* @property {number} x - Description.
|
||||
*/
|
||||
this.x = x;
|
||||
|
||||
/**
|
||||
* @property {number} y - Description.
|
||||
*/
|
||||
this.y = y;
|
||||
|
||||
this.prevX = x;
|
||||
this.prevY = y;
|
||||
|
||||
/**
|
||||
* @property {Description} position - Description.
|
||||
*/
|
||||
this.position.x = x;
|
||||
this.position.y = y;
|
||||
|
||||
/**
|
||||
* Should this Sprite be automatically culled if out of range of the camera?
|
||||
* A culled sprite has its visible property set to 'false'.
|
||||
* Note that this check doesn't look at this Sprites children, which may still be in camera range.
|
||||
* So you should set autoCull to false if the Sprite will have children likely to still be in camera range.
|
||||
*
|
||||
* @property autoCull
|
||||
* @type Boolean
|
||||
*/
|
||||
* Should this Sprite be automatically culled if out of range of the camera?
|
||||
* A culled sprite has its visible property set to 'false'.
|
||||
* Note that this check doesn't look at this Sprites children, which may still be in camera range.
|
||||
* So you should set autoCull to false if the Sprite will have children likely to still be in camera range.
|
||||
*
|
||||
* @property {bool} autoCull
|
||||
* @default
|
||||
*/
|
||||
this.autoCull = false;
|
||||
|
||||
// Replaces the PIXI.Point with a slightly more flexible one
|
||||
/**
|
||||
* @property {Phaser.Point} scale - Replaces the PIXI.Point with a slightly more flexible one.
|
||||
*/
|
||||
this.scale = new Phaser.Point(1, 1);
|
||||
|
||||
// Influence of camera movement upon the position
|
||||
/**
|
||||
* @property {Phaser.Point} scrollFactor - Influence of camera movement upon the position.
|
||||
*/
|
||||
this.scrollFactor = new Phaser.Point(1, 1);
|
||||
|
||||
// A mini cache for storing all of the calculated values
|
||||
/**
|
||||
* @property {Phaser.Point} _cache - A mini cache for storing all of the calculated values.
|
||||
* @private
|
||||
*/
|
||||
this._cache = {
|
||||
|
||||
dirty: false,
|
||||
@@ -157,25 +227,73 @@ Phaser.Sprite = function (game, x, y, key, frame) {
|
||||
cameraVisible: true
|
||||
|
||||
};
|
||||
|
||||
// Corner point defaults
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} offset - Corner point defaults.
|
||||
*/
|
||||
this.offset = new Phaser.Point;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} center - Description.
|
||||
*/
|
||||
this.center = new Phaser.Point(x + Math.floor(this._cache.width / 2), y + Math.floor(this._cache.height / 2));
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} topLeft - Description.
|
||||
*/
|
||||
this.topLeft = new Phaser.Point(x, y);
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} topRight - Description.
|
||||
*/
|
||||
this.topRight = new Phaser.Point(x + this._cache.width, y);
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} bottomRight - Description.
|
||||
*/
|
||||
this.bottomRight = new Phaser.Point(x + this._cache.width, y + this._cache.height);
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} bottomLeft - Description.
|
||||
*/
|
||||
this.bottomLeft = new Phaser.Point(x, y + this._cache.height);
|
||||
|
||||
/**
|
||||
* @property {Phaser.Rectangle} bounds - Description.
|
||||
*/
|
||||
this.bounds = new Phaser.Rectangle(x, y, this._cache.width, this._cache.height);
|
||||
|
||||
// Set-up the physics body
|
||||
|
||||
/**
|
||||
* @property {Phaser.Physics.Arcade.Body} body - Set-up the physics body.
|
||||
*/
|
||||
this.body = new Phaser.Physics.Arcade.Body(this);
|
||||
|
||||
/**
|
||||
* @property {Description} velocity - Description.
|
||||
*/
|
||||
this.velocity = this.body.velocity;
|
||||
|
||||
/**
|
||||
* @property {Description} acceleration - Description.
|
||||
*/
|
||||
this.acceleration = this.body.acceleration;
|
||||
|
||||
// World bounds check
|
||||
/**
|
||||
* @property {Description} inWorld - World bounds check.
|
||||
*/
|
||||
this.inWorld = Phaser.Rectangle.intersects(this.bounds, this.game.world.bounds);
|
||||
|
||||
/**
|
||||
* @property {number} inWorldThreshold - World bounds check.
|
||||
* @default
|
||||
*/
|
||||
this.inWorldThreshold = 0;
|
||||
|
||||
/**
|
||||
* @property {bool} _outOfBoundsFired - Description.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._outOfBoundsFired = false;
|
||||
|
||||
};
|
||||
@@ -185,8 +303,9 @@ Phaser.Sprite.prototype = Object.create(PIXI.Sprite.prototype);
|
||||
Phaser.Sprite.prototype.constructor = Phaser.Sprite;
|
||||
|
||||
/**
|
||||
* Automatically called by World.update. You can create your own update in Objects that extend Phaser.Sprite.
|
||||
*/
|
||||
* Automatically called by World.update. You can create your own update in Objects that extend Phaser.Sprite.
|
||||
* @method Phaser.Sprite.prototype.preUpdate
|
||||
*/
|
||||
Phaser.Sprite.prototype.preUpdate = function() {
|
||||
|
||||
if (!this.exists)
|
||||
@@ -331,9 +450,13 @@ Phaser.Sprite.prototype.deltaY = function () {
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the sprite so its center is located on the given x and y coordinates.
|
||||
* Doesn't change the origin of the sprite.
|
||||
*/
|
||||
* Moves the sprite so its center is located on the given x and y coordinates.
|
||||
* Doesn't change the origin of the sprite.
|
||||
*
|
||||
* @method Phaser.Sprite.prototype.centerOn
|
||||
* @param {number} x - Description.
|
||||
* @param {number} y - Description.
|
||||
*/
|
||||
Phaser.Sprite.prototype.centerOn = function(x, y) {
|
||||
|
||||
this.x = x + (this.x - this.center.x);
|
||||
@@ -341,6 +464,11 @@ Phaser.Sprite.prototype.centerOn = function(x, y) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*
|
||||
* @method Phaser.Sprite.prototype.revive
|
||||
*/
|
||||
Phaser.Sprite.prototype.revive = function() {
|
||||
|
||||
this.alive = true;
|
||||
@@ -350,6 +478,11 @@ Phaser.Sprite.prototype.revive = function() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*
|
||||
* @method Phaser.Sprite.prototype.kill
|
||||
*/
|
||||
Phaser.Sprite.prototype.kill = function() {
|
||||
|
||||
this.alive = false;
|
||||
@@ -359,6 +492,11 @@ Phaser.Sprite.prototype.kill = function() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*
|
||||
* @method Phaser.Sprite.prototype.reset
|
||||
*/
|
||||
Phaser.Sprite.prototype.reset = function(x, y) {
|
||||
|
||||
this.x = x;
|
||||
@@ -373,6 +511,11 @@ Phaser.Sprite.prototype.reset = function(x, y) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*
|
||||
* @method Phaser.Sprite.prototype.updateBounds
|
||||
*/
|
||||
Phaser.Sprite.prototype.updateBounds = function() {
|
||||
|
||||
// Update the edge points
|
||||
@@ -421,6 +564,15 @@ Phaser.Sprite.prototype.updateBounds = function() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*
|
||||
* @method Phaser.Sprite.prototype.getLocalPosition
|
||||
* @param {Description} p - Description.
|
||||
* @param {number} x - Description.
|
||||
* @param {number} y - Description.
|
||||
* @return {Description} Description.
|
||||
*/
|
||||
Phaser.Sprite.prototype.getLocalPosition = function(p, x, y) {
|
||||
|
||||
p.x = ((this._cache.a11 * this._cache.id * x + -this._cache.a01 * this._cache.id * y + (this._cache.a12 * this._cache.a01 - this._cache.a02 * this._cache.a11) * this._cache.id) * this._cache.scaleX) + this._cache.a02;
|
||||
@@ -430,6 +582,15 @@ Phaser.Sprite.prototype.getLocalPosition = function(p, x, y) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*
|
||||
* @method Phaser.Sprite.prototype.getLocalUnmodifiedPosition
|
||||
* @param {Description} p - Description.
|
||||
* @param {number} x - Description.
|
||||
* @param {number} y - Description.
|
||||
* @return {Description} Description.
|
||||
*/
|
||||
Phaser.Sprite.prototype.getLocalUnmodifiedPosition = function(p, x, y) {
|
||||
|
||||
p.x = this._cache.a11 * this._cache.idi * x + -this._cache.i01 * this._cache.idi * y + (this._cache.a12 * this._cache.i01 - this._cache.a02 * this._cache.a11) * this._cache.idi;
|
||||
@@ -439,6 +600,11 @@ Phaser.Sprite.prototype.getLocalUnmodifiedPosition = function(p, x, y) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*
|
||||
* @method Phaser.Sprite.prototype.bringToTop
|
||||
*/
|
||||
Phaser.Sprite.prototype.bringToTop = function() {
|
||||
|
||||
if (this.group)
|
||||
@@ -452,6 +618,13 @@ Phaser.Sprite.prototype.bringToTop = function() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*
|
||||
* @method Phaser.Sprite.prototype.bringToTop
|
||||
* @param {Phaser.Rectangle} rect - Description.
|
||||
* @return {Phaser.Rectangle} Description.
|
||||
*/
|
||||
Phaser.Sprite.prototype.getBounds = function(rect) {
|
||||
|
||||
rect = rect || new Phaser.Rectangle;
|
||||
@@ -501,67 +674,71 @@ Object.defineProperty(Phaser.Sprite.prototype, 'angle', {
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Get the animation frame number.
|
||||
* @returns {Description}
|
||||
*//**
|
||||
* Set the animation frame by frame number.
|
||||
* @param {Description} value - Description
|
||||
*/
|
||||
Object.defineProperty(Phaser.Sprite.prototype, "frame", {
|
||||
|
||||
/**
|
||||
* Get the animation frame number.
|
||||
*/
|
||||
get: function () {
|
||||
return this.animations.frame;
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the animation frame by frame number.
|
||||
*/
|
||||
set: function (value) {
|
||||
this.animations.frame = value;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Get the animation frame name.
|
||||
* @returns {Description}
|
||||
*//**
|
||||
* Set the animation frame by frame name.
|
||||
* @param {Description} value - Description
|
||||
*/
|
||||
Object.defineProperty(Phaser.Sprite.prototype, "frameName", {
|
||||
|
||||
/**
|
||||
* Get the animation frame name.
|
||||
*/
|
||||
get: function () {
|
||||
return this.animations.frameName;
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the animation frame by frame name.
|
||||
*/
|
||||
set: function (value) {
|
||||
this.animations.frameName = value;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Is this sprite visible to the camera or not?
|
||||
* @returns {bool}
|
||||
*/
|
||||
Object.defineProperty(Phaser.Sprite.prototype, "inCamera", {
|
||||
|
||||
/**
|
||||
* Is this sprite visible to the camera or not?
|
||||
*/
|
||||
get: function () {
|
||||
return this._cache.cameraVisible;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Get the input enabled state of this Sprite.
|
||||
* @returns {Description}
|
||||
*//**
|
||||
* Set the ability for this sprite to receive input events.
|
||||
* @param {Description} value - Description
|
||||
*/
|
||||
Object.defineProperty(Phaser.Sprite.prototype, "crop", {
|
||||
|
||||
/**
|
||||
* Get the input enabled state of this Sprite.
|
||||
*/
|
||||
get: function () {
|
||||
|
||||
return this._cropRect;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the ability for this sprite to receive input events.
|
||||
*/
|
||||
set: function (value) {
|
||||
|
||||
if (value instanceof Phaser.Rectangle)
|
||||
@@ -590,20 +767,21 @@ Object.defineProperty(Phaser.Sprite.prototype, "crop", {
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Get the input enabled state of this Sprite.
|
||||
* @returns {Description}
|
||||
*//**
|
||||
* Set the ability for this sprite to receive input events.
|
||||
* @param {Description} value - Description
|
||||
*/
|
||||
Object.defineProperty(Phaser.Sprite.prototype, "inputEnabled", {
|
||||
|
||||
/**
|
||||
* Get the input enabled state of this Sprite.
|
||||
*/
|
||||
get: function () {
|
||||
|
||||
return (this.input.enabled);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the ability for this sprite to receive input events.
|
||||
*/
|
||||
set: function (value) {
|
||||
|
||||
if (value)
|
||||
|
||||
+72
-1
@@ -1,3 +1,21 @@
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
* @module Phaser.Text
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create a new <code>Text</code>.
|
||||
* @class Phaser.Text
|
||||
* @classdesc Description of class.
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - Current game instance.
|
||||
* @param {Description} x - Description.
|
||||
* @param {Description} y - Description.
|
||||
* @param {string} text - Description.
|
||||
* @param {string} style - Description.
|
||||
*/
|
||||
Phaser.Text = function (game, x, y, text, style) {
|
||||
|
||||
x = x || 0;
|
||||
@@ -6,15 +24,34 @@ Phaser.Text = function (game, x, y, text, style) {
|
||||
style = style || '';
|
||||
|
||||
// If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all
|
||||
/**
|
||||
* @property {bool} exists - Description.
|
||||
* @default
|
||||
*/
|
||||
this.exists = true;
|
||||
|
||||
// This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering
|
||||
/**
|
||||
* @property {bool} alive - Description.
|
||||
* @default
|
||||
*/
|
||||
this.alive = true;
|
||||
|
||||
/**
|
||||
* @property {Description} group - Description.
|
||||
* @default
|
||||
*/
|
||||
this.group = null;
|
||||
|
||||
/**
|
||||
* @property {string} name - Description.
|
||||
* @default
|
||||
*/
|
||||
this.name = '';
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - A reference to the currently running game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
this._text = text;
|
||||
@@ -22,19 +59,39 @@ Phaser.Text = function (game, x, y, text, style) {
|
||||
|
||||
PIXI.Text.call(this, text, style);
|
||||
|
||||
/**
|
||||
* @property {Description} type - Description.
|
||||
*/
|
||||
this.type = Phaser.TEXT;
|
||||
|
||||
/**
|
||||
* @property {Description} position - Description.
|
||||
*/
|
||||
this.position.x = this.x = x;
|
||||
this.position.y = this.y = y;
|
||||
|
||||
// Replaces the PIXI.Point with a slightly more flexible one
|
||||
/**
|
||||
* @property {Phaser.Point} anchor - Description.
|
||||
*/
|
||||
this.anchor = new Phaser.Point();
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} scale - Description.
|
||||
*/
|
||||
this.scale = new Phaser.Point(1, 1);
|
||||
|
||||
// Influence of camera movement upon the position
|
||||
/**
|
||||
* @property {Phaser.Point} scrollFactor - Description.
|
||||
*/
|
||||
this.scrollFactor = new Phaser.Point(1, 1);
|
||||
|
||||
// A mini cache for storing all of the calculated values
|
||||
/**
|
||||
* @property {Description} _cache - Description.
|
||||
* @private
|
||||
*/
|
||||
this._cache = {
|
||||
|
||||
dirty: false,
|
||||
@@ -53,6 +110,9 @@ Phaser.Text = function (game, x, y, text, style) {
|
||||
this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x);
|
||||
this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y);
|
||||
|
||||
/**
|
||||
* @property {bool} renderable - Description.
|
||||
*/
|
||||
this.renderable = true;
|
||||
|
||||
};
|
||||
@@ -60,7 +120,11 @@ Phaser.Text = function (game, x, y, text, style) {
|
||||
Phaser.Text.prototype = Object.create(PIXI.Text.prototype);
|
||||
Phaser.Text.prototype.constructor = Phaser.Text;
|
||||
|
||||
// Automatically called by World.update
|
||||
|
||||
/**
|
||||
* Automatically called by World.update.
|
||||
* @method Phaser.Text.prototype.update
|
||||
*/
|
||||
Phaser.Text.prototype.update = function() {
|
||||
|
||||
if (!this.exists)
|
||||
@@ -82,6 +146,13 @@ Phaser.Text.prototype.update = function() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get
|
||||
* @returns {Description}
|
||||
*//**
|
||||
* Set
|
||||
* @param {Description} value - Description
|
||||
*/
|
||||
Object.defineProperty(Phaser.Text.prototype, 'angle', {
|
||||
|
||||
get: function() {
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
* @module Phaser.TileSprite
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create a new <code>TileSprite</code>.
|
||||
* @class Phaser.Tilemap
|
||||
* @classdesc Class description.
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - Current game instance.
|
||||
* @param {object} x - Description.
|
||||
* @param {object} y - Description.
|
||||
* @param {number} width - Description.
|
||||
* @param {number} height - Description.
|
||||
* @param {string} key - Description.
|
||||
* @param {Description} frame - Description.
|
||||
*/
|
||||
Phaser.TileSprite = function (game, x, y, width, height, key, frame) {
|
||||
|
||||
x = x || 0;
|
||||
@@ -9,26 +29,26 @@ Phaser.TileSprite = function (game, x, y, width, height, key, frame) {
|
||||
|
||||
Phaser.Sprite.call(this, game, x, y, key, frame);
|
||||
|
||||
/**
|
||||
* @property {Description} texture - Description.
|
||||
*/
|
||||
this.texture = PIXI.TextureCache[key];
|
||||
|
||||
PIXI.TilingSprite.call(this, this.texture, width, height);
|
||||
|
||||
/**
|
||||
* @property {Description} type - Description.
|
||||
*/
|
||||
this.type = Phaser.TILESPRITE;
|
||||
|
||||
/**
|
||||
* The scaling of the image that is being tiled
|
||||
*
|
||||
* @property tileScale
|
||||
* @type Point
|
||||
*/
|
||||
* @property {Point} tileScale - The scaling of the image that is being tiled.
|
||||
*/
|
||||
this.tileScale = new Phaser.Point(1, 1);
|
||||
|
||||
/**
|
||||
* The offset position of the image that is being tiled
|
||||
*
|
||||
* @property tilePosition
|
||||
* @type Point
|
||||
*/
|
||||
* @property {Point} tilePosition - The offset position of the image that is being tiled.
|
||||
*/
|
||||
this.tilePosition = new Phaser.Point(0, 0);
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user