2018-02-12 16:01:20 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
2022-02-28 14:29:51 +00:00
|
|
|
* @copyright 2022 Photon Storm Ltd.
|
2019-05-10 15:15:04 +00:00
|
|
|
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
2018-02-12 16:01:20 +00:00
|
|
|
*/
|
|
|
|
|
2018-02-01 00:25:33 +00:00
|
|
|
/**
|
|
|
|
* Provides methods used for getting and setting the Scroll Factor of a Game Object.
|
2018-03-27 12:52:58 +00:00
|
|
|
*
|
2019-02-12 12:48:41 +00:00
|
|
|
* @namespace Phaser.GameObjects.Components.ScrollFactor
|
2018-02-01 00:25:33 +00:00
|
|
|
* @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.
|
2018-03-27 12:52:58 +00:00
|
|
|
*
|
2018-02-01 00:25:33 +00:00
|
|
|
* 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.
|
2018-03-27 12:52:58 +00:00
|
|
|
*
|
2018-02-01 00:25:33 +00:00
|
|
|
* 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.
|
2022-02-28 14:29:51 +00:00
|
|
|
*
|
2018-08-20 18:19:53 +00:00
|
|
|
* Please be aware that scroll factor values other than 1 are not taken in to consideration when
|
|
|
|
* calculating physics collisions. Bodies always collide based on their world position, but changing
|
|
|
|
* the scroll factor is a visual adjustment to where the textures are rendered, which can offset
|
|
|
|
* them from physics bodies if not accounted for in your code.
|
2018-03-27 12:52:58 +00:00
|
|
|
*
|
2018-02-01 00:25:33 +00:00
|
|
|
* @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.
|
2018-03-27 12:52:58 +00:00
|
|
|
*
|
2018-02-01 00:25:33 +00:00
|
|
|
* 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.
|
2018-03-27 12:52:58 +00:00
|
|
|
*
|
2018-02-01 00:25:33 +00:00
|
|
|
* 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.
|
2022-02-28 14:29:51 +00:00
|
|
|
*
|
2018-08-20 18:19:53 +00:00
|
|
|
* Please be aware that scroll factor values other than 1 are not taken in to consideration when
|
|
|
|
* calculating physics collisions. Bodies always collide based on their world position, but changing
|
|
|
|
* the scroll factor is a visual adjustment to where the textures are rendered, which can offset
|
|
|
|
* them from physics bodies if not accounted for in your code.
|
2018-03-27 12:52:58 +00:00
|
|
|
*
|
2018-02-01 00:25:33 +00:00
|
|
|
* @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.
|
2018-03-27 12:52:58 +00:00
|
|
|
*
|
2018-02-01 00:25:33 +00:00
|
|
|
* 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.
|
2018-03-27 12:52:58 +00:00
|
|
|
*
|
2018-02-01 00:25:33 +00:00
|
|
|
* 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.
|
2022-02-28 14:29:51 +00:00
|
|
|
*
|
2018-08-20 18:19:53 +00:00
|
|
|
* Please be aware that scroll factor values other than 1 are not taken in to consideration when
|
|
|
|
* calculating physics collisions. Bodies always collide based on their world position, but changing
|
|
|
|
* the scroll factor is a visual adjustment to where the textures are rendered, which can offset
|
|
|
|
* them from physics bodies if not accounted for in your code.
|
2018-03-27 12:52:58 +00:00
|
|
|
*
|
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.
|
2018-03-27 12:52:58 +00:00
|
|
|
* @param {number} [y=x] - The vertical scroll factor of this Game Object. If not set it will use the `x` value.
|
|
|
|
*
|
2018-05-22 04:46:26 +00:00
|
|
|
* @return {this} This Game Object instance.
|
2018-02-01 00:25:33 +00:00
|
|
|
*/
|
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;
|