phaser/src/gameobjects/components/ScrollFactor.js

81 lines
2.9 KiB
JavaScript
Raw Normal View History

2018-02-01 00:25:33 +00:00
/**
* Provides methods used for getting and setting the Scroll Factor of a Game Object.
*
* @name Phaser.GameObjects.Components.ScrollFactor
* @since 3.0.0
*/
2017-06-22 02:19:03 +00:00
var ScrollFactor = {
2017-06-26 12:17:31 +00:00
2018-02-01 00:25:33 +00:00
/**
* The horizontal scroll factor of this Game Object.
*
* The scroll factor controls the influence of the movement of a Camera upon this Game Object.
*
* When a camera scrolls it will change the location at which this Game Object is rendered on-screen.
* It does not change the Game Objects actual position values.
*
* A value of 1 means it will move exactly in sync with a camera.
* A value of 0 means it will not move at all, even if the camera moves.
* Other values control the degree to which the camera movement is mapped to this Game Object.
*
* @name Phaser.GameObjects.Components.ScrollFactor#scrollFactorX
* @type {number}
* @default 1
* @since 3.0.0
*/
2018-01-04 15:21:02 +00:00
scrollFactorX: 1,
2018-02-01 00:25:33 +00:00
/**
* The vertical scroll factor of this Game Object.
*
* The scroll factor controls the influence of the movement of a Camera upon this Game Object.
*
* When a camera scrolls it will change the location at which this Game Object is rendered on-screen.
* It does not change the Game Objects actual position values.
*
* A value of 1 means it will move exactly in sync with a camera.
* A value of 0 means it will not move at all, even if the camera moves.
* Other values control the degree to which the camera movement is mapped to this Game Object.
*
* @name Phaser.GameObjects.Components.ScrollFactor#scrollFactorY
* @type {number}
* @default 1
* @since 3.0.0
*/
2018-01-04 15:21:02 +00:00
scrollFactorY: 1,
2017-06-26 12:17:31 +00:00
2018-02-01 00:25:33 +00:00
/**
* Sets the scroll factor of this Game Object.
*
* The scroll factor controls the influence of the movement of a Camera upon this Game Object.
*
* When a camera scrolls it will change the location at which this Game Object is rendered on-screen.
* It does not change the Game Objects actual position values.
*
* A value of 1 means it will move exactly in sync with a camera.
* A value of 0 means it will not move at all, even if the camera moves.
* Other values control the degree to which the camera movement is mapped to this Game Object.
*
2018-02-01 01:36:52 +00:00
* @method Phaser.GameObjects.Components.ScrollFactor#setScrollFactor
2018-02-01 00:25:33 +00:00
* @since 3.0.0
*
* @param {number} x - The horizontal scroll factor of this Game Object.
* @param {number} [y] - The vertical scroll factor of this Game Object. If not set it will use the `x` value.
*
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
*/
2017-06-26 12:17:31 +00:00
setScrollFactor: function (x, y)
{
2017-06-26 14:07:53 +00:00
if (y === undefined) { y = x; }
2017-06-26 12:17:31 +00:00
this.scrollFactorX = x;
this.scrollFactorY = y;
return this;
}
2017-06-22 02:19:03 +00:00
};
module.exports = ScrollFactor;