2018-02-12 16:01:20 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
|
|
|
* @copyright 2018 Photon Storm Ltd.
|
|
|
|
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
|
|
|
*/
|
|
|
|
|
2017-02-23 03:10:48 +00:00
|
|
|
var Class = require('../../utils/Class');
|
2017-07-04 00:59:31 +00:00
|
|
|
var Components = require('../components');
|
2018-02-06 01:08:43 +00:00
|
|
|
var GameObject = require('../GameObject');
|
2017-02-23 03:10:48 +00:00
|
|
|
var ImageRender = require('./ImageRender');
|
|
|
|
|
2018-02-06 01:08:43 +00:00
|
|
|
/**
|
2018-02-07 15:27:21 +00:00
|
|
|
* @classdesc
|
2018-02-06 14:13:30 +00:00
|
|
|
* An Image Game Object.
|
2018-03-20 14:56:31 +00:00
|
|
|
*
|
2018-02-06 14:13:30 +00:00
|
|
|
* An Image is a light-weight Game Object useful for the display of static images in your game,
|
|
|
|
* such as logos, backgrounds, scenery or other non-animated elements. Images can have input
|
|
|
|
* events and physics bodies, or be tweened, tinted or scrolled. The main difference between an
|
|
|
|
* Image and a Sprite is that you cannot animate an Image as they do not have the Animation component.
|
2018-02-06 01:08:43 +00:00
|
|
|
*
|
|
|
|
* @class Image
|
|
|
|
* @extends Phaser.GameObjects.GameObject
|
|
|
|
* @memberOf Phaser.GameObjects
|
|
|
|
* @constructor
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @extends Phaser.GameObjects.Components.Alpha
|
|
|
|
* @extends Phaser.GameObjects.Components.BlendMode
|
|
|
|
* @extends Phaser.GameObjects.Components.Depth
|
|
|
|
* @extends Phaser.GameObjects.Components.Flip
|
|
|
|
* @extends Phaser.GameObjects.Components.GetBounds
|
2018-04-20 17:57:49 +00:00
|
|
|
* @extends Phaser.GameObjects.Components.Mask
|
2018-02-06 01:08:43 +00:00
|
|
|
* @extends Phaser.GameObjects.Components.Origin
|
|
|
|
* @extends Phaser.GameObjects.Components.Pipeline
|
|
|
|
* @extends Phaser.GameObjects.Components.ScaleMode
|
|
|
|
* @extends Phaser.GameObjects.Components.ScrollFactor
|
|
|
|
* @extends Phaser.GameObjects.Components.Size
|
2018-07-05 12:06:28 +00:00
|
|
|
* @extends Phaser.GameObjects.Components.TextureCrop
|
2018-02-06 01:08:43 +00:00
|
|
|
* @extends Phaser.GameObjects.Components.Tint
|
|
|
|
* @extends Phaser.GameObjects.Components.Transform
|
|
|
|
* @extends Phaser.GameObjects.Components.Visible
|
|
|
|
*
|
2018-02-06 14:13:30 +00:00
|
|
|
* @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time.
|
|
|
|
* @param {number} x - The horizontal position of this Game Object in the world.
|
|
|
|
* @param {number} y - The vertical position of this Game Object in the world.
|
|
|
|
* @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
|
2018-03-20 14:56:31 +00:00
|
|
|
* @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with.
|
2018-02-06 01:08:43 +00:00
|
|
|
*/
|
2017-02-23 03:10:48 +00:00
|
|
|
var Image = new Class({
|
|
|
|
|
2017-04-05 01:10:48 +00:00
|
|
|
Extends: GameObject,
|
|
|
|
|
2017-02-23 03:10:48 +00:00
|
|
|
Mixins: [
|
|
|
|
Components.Alpha,
|
|
|
|
Components.BlendMode,
|
2018-02-01 00:50:15 +00:00
|
|
|
Components.Depth,
|
2017-03-20 23:37:17 +00:00
|
|
|
Components.Flip,
|
2017-02-24 05:02:39 +00:00
|
|
|
Components.GetBounds,
|
2018-04-20 17:57:49 +00:00
|
|
|
Components.Mask,
|
2017-03-02 02:06:13 +00:00
|
|
|
Components.Origin,
|
2018-01-29 21:46:48 +00:00
|
|
|
Components.Pipeline,
|
2017-02-23 03:10:48 +00:00
|
|
|
Components.ScaleMode,
|
2017-07-04 11:01:27 +00:00
|
|
|
Components.ScrollFactor,
|
2017-02-24 05:02:39 +00:00
|
|
|
Components.Size,
|
2018-07-05 12:06:28 +00:00
|
|
|
Components.TextureCrop,
|
2017-07-04 11:01:27 +00:00
|
|
|
Components.Tint,
|
2017-02-24 05:02:39 +00:00
|
|
|
Components.Transform,
|
2017-02-23 03:10:48 +00:00
|
|
|
Components.Visible,
|
|
|
|
ImageRender
|
|
|
|
],
|
|
|
|
|
|
|
|
initialize:
|
|
|
|
|
2017-07-14 13:30:20 +00:00
|
|
|
function Image (scene, x, y, texture, frame)
|
2017-02-23 03:10:48 +00:00
|
|
|
{
|
2017-07-14 13:30:20 +00:00
|
|
|
GameObject.call(this, scene, 'Image');
|
2017-02-23 03:10:48 +00:00
|
|
|
|
|
|
|
this.setTexture(texture, frame);
|
2017-02-24 01:45:15 +00:00
|
|
|
this.setPosition(x, y);
|
2017-03-02 04:00:39 +00:00
|
|
|
this.setSizeToFrame();
|
2018-02-09 15:23:26 +00:00
|
|
|
this.setOriginFromFrame();
|
2018-01-29 21:46:48 +00:00
|
|
|
this.initPipeline('TextureTintPipeline');
|
2016-11-28 16:55:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
2016-12-07 02:28:22 +00:00
|
|
|
|
|
|
|
module.exports = Image;
|