2014-02-06 19:34:05 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
|
|
|
* @copyright 2014 Photon Storm Ltd.
|
|
|
|
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2014-09-16 16:35:08 +00:00
|
|
|
* An Image is a light-weight object you can use to display anything that doesn't need physics or animation.
|
2014-02-07 17:14:10 +00:00
|
|
|
* It can still rotate, scale, crop and receive input events. This makes it perfect for logos, backgrounds, simple buttons and other non-Sprite graphics.
|
2014-02-06 19:34:05 +00:00
|
|
|
*
|
2014-09-16 16:35:08 +00:00
|
|
|
* @class Phaser.Image
|
|
|
|
* @extends PIXI.Sprite
|
2014-02-06 19:34:05 +00:00
|
|
|
* @constructor
|
|
|
|
* @param {Phaser.Game} game - A reference to the currently running game.
|
2014-05-10 06:15:16 +00:00
|
|
|
* @param {number} x - The x coordinate of the Image. The coordinate is relative to any parent container this Image may be in.
|
2014-02-07 06:52:49 +00:00
|
|
|
* @param {number} y - The y coordinate of the Image. The coordinate is relative to any parent container this Image may be in.
|
|
|
|
* @param {string|Phaser.RenderTexture|Phaser.BitmapData|PIXI.Texture} key - The texture used by the Image during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture, BitmapData or PIXI.Texture.
|
|
|
|
* @param {string|number} frame - If this Image is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index.
|
2014-02-06 19:34:05 +00:00
|
|
|
*/
|
|
|
|
Phaser.Image = function (game, x, y, key, frame) {
|
|
|
|
|
|
|
|
x = x || 0;
|
|
|
|
y = y || 0;
|
|
|
|
key = key || null;
|
|
|
|
frame = frame || null;
|
2014-03-23 07:59:28 +00:00
|
|
|
|
2014-02-06 19:34:05 +00:00
|
|
|
/**
|
|
|
|
* @property {number} type - The const type of this object.
|
|
|
|
* @readonly
|
|
|
|
*/
|
|
|
|
this.type = Phaser.IMAGE;
|
|
|
|
|
2014-02-06 22:42:23 +00:00
|
|
|
PIXI.Sprite.call(this, PIXI.TextureCache['__default']);
|
2014-02-06 19:34:05 +00:00
|
|
|
|
2015-02-17 06:00:41 +00:00
|
|
|
Phaser.Utils.mixinPrototype(this, Phaser.Component.Core.prototype);
|
2015-02-16 17:22:51 +00:00
|
|
|
|
2015-02-17 06:00:41 +00:00
|
|
|
var components = [
|
|
|
|
'Angle',
|
|
|
|
'Animation',
|
|
|
|
'AutoCull',
|
|
|
|
'Bounds',
|
|
|
|
'BringToTop',
|
|
|
|
'Crop',
|
|
|
|
'Destroy',
|
|
|
|
'FixedToCamera',
|
|
|
|
'InputEnabled',
|
|
|
|
'LifeSpan',
|
|
|
|
'LoadTexture',
|
|
|
|
'Overlap',
|
|
|
|
'Reset',
|
|
|
|
'Smoothed'
|
|
|
|
];
|
2015-02-16 17:22:51 +00:00
|
|
|
|
2015-02-17 06:00:41 +00:00
|
|
|
Phaser.Component.Core.install.call(this, components);
|
|
|
|
Phaser.Component.Core.init.call(this, game, x, y, key, frame);
|
2014-08-28 16:01:01 +00:00
|
|
|
|
2014-02-06 19:34:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Phaser.Image.prototype = Object.create(PIXI.Sprite.prototype);
|
|
|
|
Phaser.Image.prototype.constructor = Phaser.Image;
|
|
|
|
|
2015-02-25 02:49:50 +00:00
|
|
|
Phaser.Image.prototype.preUpdateInWorld = Phaser.Component.InWorld.preUpdate;
|
|
|
|
Phaser.Image.prototype.preUpdateCore = Phaser.Component.Core.preUpdate;
|
|
|
|
|
2014-02-06 19:34:05 +00:00
|
|
|
/**
|
2014-02-07 02:31:29 +00:00
|
|
|
* Automatically called by World.preUpdate.
|
2014-02-06 19:34:05 +00:00
|
|
|
*
|
|
|
|
* @method Phaser.Image#preUpdate
|
|
|
|
* @memberof Phaser.Image
|
|
|
|
*/
|
|
|
|
Phaser.Image.prototype.preUpdate = function() {
|
|
|
|
|
2015-02-25 02:49:50 +00:00
|
|
|
if (!this.preUpdateInWorld())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2014-02-07 17:14:10 +00:00
|
|
|
|
2015-02-25 02:49:50 +00:00
|
|
|
return this.preUpdateCore();
|
2014-02-06 19:34:05 +00:00
|
|
|
|
2014-03-23 08:40:24 +00:00
|
|
|
};
|