phaser/src/gameobjects/TileSprite.js

48 lines
1.7 KiB
JavaScript
Raw Normal View History

2013-10-01 12:54:29 +00:00
/**
* @author Richard Davey <rich@photonstorm.com>
2014-02-05 05:54:25 +00:00
* @copyright 2014 Photon Storm Ltd.
2013-10-01 12:54:29 +00:00
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* 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
2013-10-01 12:54:29 +00:00
* @constructor
* @param {Phaser.Game} game - Current game instance.
* @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.
2013-10-01 12:54:29 +00:00
*/
Phaser.TileSprite = function (game, x, y, width, height, key) {
2013-09-03 02:19:42 +00:00
x = x || 0;
y = y || 0;
width = width || 256;
height = height || 256;
key = key || null;
/**
* @property {PIXI.Texture} texture - The texture that the sprite renders with.
2013-10-01 12:54:29 +00:00
*/
this.texture = PIXI.TextureCache[key];
2013-09-03 02:19:42 +00:00
PIXI.TilingSprite.call(this, this.texture, width, height);
2013-09-03 02:19:42 +00:00
/**
* @property {number} type - The const type of this object.
* @readonly
2013-10-01 12:54:29 +00:00
*/
this.type = Phaser.TILESPRITE;
this.position.x = x;
this.position.y = y;
2013-09-03 02:19:42 +00:00
};
Phaser.TileSprite.prototype = Object.create(PIXI.TilingSprite.prototype);
2013-09-03 02:19:42 +00:00
Phaser.TileSprite.prototype.constructor = Phaser.TileSprite;