phaser/src/gameobjects/components/Flip.js

143 lines
3.8 KiB
JavaScript
Raw Normal View History

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}
*/
2018-02-01 00:04:45 +00:00
/**
* Provides methods used for visually flipping a Game Object.
* Should be applied as a mixin and not used directly.
*
* @name Phaser.GameObjects.Components.Flip
* @since 3.0.0
*/
var Flip = {
2018-02-01 00:04:45 +00:00
/**
* The horizontally flipped state of the Game Object.
* A Game Object that is flipped horizontally will render inversed on the horizontal axis.
* Flipping always takes place from the middle of the texture and does not impact the scale value.
*
* @name Phaser.GameObjects.Components.Flip#flipX
* @type {boolean}
* @default false
* @since 3.0.0
*/
flipX: false,
2018-02-01 00:04:45 +00:00
/**
* The vertically flipped state of the Game Object.
* A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down)
* Flipping always takes place from the middle of the texture and does not impact the scale value.
*
* @name Phaser.GameObjects.Components.Flip#flipY
* @type {boolean}
* @default false
* @since 3.0.0
*/
flipY: false,
2018-02-01 00:04:45 +00:00
/**
* Toggles the horizontal flipped state of this Game Object.
*
2018-02-01 01:36:52 +00:00
* @method Phaser.GameObjects.Components.Flip#toggleFlipX
2018-02-01 00:04:45 +00:00
* @since 3.0.0
*
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
*/
toggleFlipX: function ()
{
this.flipX = !this.flipX;
return this;
},
2018-02-01 00:04:45 +00:00
/**
* Toggles the vertical flipped state of this Game Object.
*
2018-02-01 01:36:52 +00:00
* @method Phaser.GameObjects.Components.Flip#toggleFlipY
2018-02-01 00:04:45 +00:00
* @since 3.0.0
*
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
*/
2017-08-31 15:14:58 +00:00
toggleFlipY: function ()
{
this.flipY = !this.flipY;
return this;
},
2018-02-01 00:04:45 +00:00
/**
* Sets the horizontal flipped state of this Game Object.
*
2018-02-01 01:36:52 +00:00
* @method Phaser.GameObjects.Components.Flip#setFlipX
2018-02-01 00:04:45 +00:00
* @since 3.0.0
*
* @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped.
*
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
*/
2017-03-27 22:53:22 +00:00
setFlipX: function (value)
{
this.flipX = value;
return this;
},
2018-02-01 00:04:45 +00:00
/**
* Sets the vertical flipped state of this Game Object.
*
2018-02-01 01:36:52 +00:00
* @method Phaser.GameObjects.Components.Flip#setFlipY
2018-02-01 00:04:45 +00:00
* @since 3.0.0
*
* @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped.
*
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
*/
2017-03-27 22:53:22 +00:00
setFlipY: function (value)
{
2017-08-31 15:14:58 +00:00
this.flipY = value;
2017-03-27 22:53:22 +00:00
return this;
},
2018-02-01 00:04:45 +00:00
/**
* Sets the horizontal and vertical flipped state of this Game Object.
*
2018-02-01 01:36:52 +00:00
* @method Phaser.GameObjects.Components.Flip#setFlip
2018-02-01 00:04:45 +00:00
* @since 3.0.0
*
* @param {boolean} x - The horizontal flipped state. `false` for no flip, or `true` to be flipped.
* @param {boolean} y - The horizontal flipped state. `false` for no flip, or `true` to be flipped.
*
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
*/
2017-03-27 22:53:22 +00:00
setFlip: function (x, y)
{
this.flipX = x;
this.flipY = y;
return this;
},
2018-02-01 00:04:45 +00:00
/**
* Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state.
*
2018-02-01 01:36:52 +00:00
* @method Phaser.GameObjects.Components.Flip#resetFlip
2018-02-01 00:04:45 +00:00
* @since 3.0.0
*
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
*/
resetFlip: function ()
{
this.flipX = false;
this.flipY = false;
2018-02-01 00:04:45 +00:00
return this;
}
};
2017-03-27 22:53:22 +00:00
module.exports = Flip;