From 90e9edbf05656c576f14d273bd89f104cc9d9f8d Mon Sep 17 00:00:00 2001 From: photonstorm Date: Thu, 13 Feb 2014 15:03:46 +0000 Subject: [PATCH] Updated TileSprite so it just directly extends the Pixi original. This means no input events or body for a TileSprite. Removed un-needed stuff from Graphics. Removed un-used events. Made docs in StateManager more clear re: shutdown (#410) --- src/core/StateManager.js | 9 ++- src/gameobjects/Events.js | 3 - src/gameobjects/Graphics.js | 9 --- src/gameobjects/TileSprite.js | 133 +++------------------------------- 4 files changed, 16 insertions(+), 138 deletions(-) diff --git a/src/core/StateManager.js b/src/core/StateManager.js index 757a3879..a7ebbe06 100644 --- a/src/core/StateManager.js +++ b/src/core/StateManager.js @@ -203,11 +203,12 @@ Phaser.StateManager.prototype = { }, /** - * Start the given state + * Start the given State. If a State is already running then State.shutDown will be called (if it exists) before switching to the new State. + * * @method Phaser.StateManager#start * @param {string} key - The key of the state you want to start. - * @param {boolean} [clearWorld] - clear everything in the world? (Default to true) - * @param {boolean} [clearCache] - clear asset cache? (Default to false and ONLY available when clearWorld=true) + * @param {boolean} [clearWorld=true] - Clear everything in the world? This clears the World display list fully (but not the Stage, so if you've added your own objects to the Stage they will need managing directly) + * @param {boolean} [clearCache=false] - Clear the Game.Cache? This purges out all loaded assets. The default is false and you must have clearWorld=true if you want to clearCache as well. */ start: function (key, clearWorld, clearCache) { @@ -280,7 +281,7 @@ Phaser.StateManager.prototype = { }, /** - * Checks i a given phaser state is valid. + * Checks if a given phaser state is valid. * State must exist and have at least one callback function registered.. * @method Phaser.StateManager#checkState * @param {string} key - The key of the state you want to check. diff --git a/src/gameobjects/Events.js b/src/gameobjects/Events.js index e3521491..d45d577a 100644 --- a/src/gameobjects/Events.js +++ b/src/gameobjects/Events.js @@ -42,9 +42,6 @@ Phaser.Events = function (sprite) { this.onAnimationComplete = null; this.onAnimationLoop = null; - this.onBeginContact = null; - this.onEndContact = null; - }; Phaser.Events.prototype = { diff --git a/src/gameobjects/Graphics.js b/src/gameobjects/Graphics.js index d5777119..1842dc12 100644 --- a/src/gameobjects/Graphics.js +++ b/src/gameobjects/Graphics.js @@ -68,12 +68,3 @@ Phaser.Graphics.prototype.drawPolygon = function (poly) { this.lineTo(poly.points[0].x, poly.points[0].y); } - -/** -* Indicates the rotation of the Button in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. -* Values outside this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement player.angle = 450 is the same as player.angle = 90. -* If you wish to work in radians instead of degrees use the rotation property instead. Working in radians is also a little faster as it doesn't have to convert the angle. -* -* @name Phaser.Button#angle -* @property {number} angle - The angle of this Button in degrees. -*/ diff --git a/src/gameobjects/TileSprite.js b/src/gameobjects/TileSprite.js index 76ef22e2..bfe115ae 100644 --- a/src/gameobjects/TileSprite.js +++ b/src/gameobjects/TileSprite.js @@ -5,15 +5,16 @@ */ /** -* A TileSprite is a Sprite whos texture is set to repeat and can be scrolled. As it scrolls the texture repeats (wraps) on the edges. -* @class Phaser.Tilemap -* @extends Phaser.Sprite +* A TileSprite is a Sprite that has a repeating texture. The texture can be scrolled and scaled and will automatically wrap on the edges as it does so. +* Please note that TileSprites have no input handler or physics bodies. +* +* @class Phaser.TileSprite * @constructor * @param {Phaser.Game} game - Current game instance. -* @param {number} x - X position of the new tileSprite. -* @param {number} y - Y position of the new tileSprite. -* @param {number} width - the width of the tilesprite. -* @param {number} height - the height of the tilesprite. +* @param {number} [x=0] - X position of the new tileSprite. +* @param {number} [y=0] - Y position of the new tileSprite. +* @param {number} [width=256] - the width of the tilesprite. +* @param {number} [height=256] - the height of the tilesprite. * @param {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. */ Phaser.TileSprite = function (game, x, y, width, height, key) { @@ -24,8 +25,6 @@ Phaser.TileSprite = function (game, x, y, width, height, key) { height = height || 256; key = key || null; - Phaser.Sprite.call(this, game, x, y, key); - /** * @property {PIXI.Texture} texture - The texture that the sprite renders with. */ @@ -39,120 +38,10 @@ Phaser.TileSprite = function (game, x, y, width, height, key) { */ this.type = Phaser.TILESPRITE; - /** - * @property {Phaser.Point} tileScale - The scaling of the image that is being tiled. - */ - this.tileScale = new Phaser.Point(1, 1); - - /** - * @property {Phaser.Point} tilePosition - The offset position of the image that is being tiled. - */ - this.tilePosition = new Phaser.Point(0, 0); - - this.body.width = width; - this.body.height = height; + this.position.x = x; + this.position.y = y; }; -Phaser.TileSprite.prototype = Phaser.Utils.extend(true, PIXI.TilingSprite.prototype, Phaser.Sprite.prototype); +Phaser.TileSprite.prototype = Object.create(PIXI.TilingSprite.prototype); Phaser.TileSprite.prototype.constructor = Phaser.TileSprite; - -/** -* Indicates the rotation of the Sprite, in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. -* Values outside this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement player.angle = 450 is the same as player.angle = 90. -* If you wish to work in radians instead of degrees use the property Sprite.rotation instead. -* @name Phaser.TileSprite#angle -* @property {number} angle - Gets or sets the Sprites angle of rotation in degrees. -*/ -Object.defineProperty(Phaser.TileSprite.prototype, 'angle', { - - get: function() { - return Phaser.Math.wrapAngle(Phaser.Math.radToDeg(this.rotation)); - }, - - set: function(value) { - this.rotation = Phaser.Math.degToRad(Phaser.Math.wrapAngle(value)); - } - -}); - -/** -* @name Phaser.TileSprite#frame -* @property {number} frame - Gets or sets the current frame index and updates the Texture Cache for display. -*/ -Object.defineProperty(Phaser.TileSprite.prototype, "frame", { - - get: function () { - return this.animations.frame; - }, - - set: function (value) { - this.animations.frame = value; - } - -}); - -/** -* @name Phaser.TileSprite#frameName -* @property {string} frameName - Gets or sets the current frame name and updates the Texture Cache for display. -*/ -Object.defineProperty(Phaser.TileSprite.prototype, "frameName", { - - get: function () { - return this.animations.frameName; - }, - - set: function (value) { - this.animations.frameName = value; - } - -}); - -/** -* @name Phaser.TileSprite#inCamera -* @property {boolean} inCamera - Is this sprite visible to the camera or not? -* @readonly -*/ -Object.defineProperty(Phaser.TileSprite.prototype, "inCamera", { - - get: function () { - return this._cache.cameraVisible; - } - -}); - -/** -* By default a Sprite won't process any input events at all. By setting inputEnabled to true the Phaser.InputHandler is -* activated for this Sprite instance and it will then start to process click/touch events and more. -* -* @name Phaser.TileSprite#inputEnabled -* @property {boolean} inputEnabled - Set to true to allow this Sprite to receive input events, otherwise false. -*/ -Object.defineProperty(Phaser.TileSprite.prototype, "inputEnabled", { - - get: function () { - - return (this.input.enabled); - - }, - - set: function (value) { - - if (value) - { - if (this.input.enabled === false) - { - this.input.start(); - } - } - else - { - if (this.input.enabled) - { - this.input.stop(); - } - } - - } - -});