Namespace: ScrollFactor

Phaser.GameObjects.Components. ScrollFactor

Provides methods used for getting and setting the Scroll Factor of a Game Object.

Since: 3.0.0
Source: src/gameobjects/components/ScrollFactor.js (Line 7)

Members


scrollFactorX :number

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.

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.

Type:
  • number
Since: 3.0.0
Default Value:
  • 1
Source: src/gameobjects/components/ScrollFactor.js (Line 16)

scrollFactorY :number

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.

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.

Type:
  • number
Since: 3.0.0
Default Value:
  • 1
Source: src/gameobjects/components/ScrollFactor.js (Line 40)

Methods


setScrollFactor(x [, y])

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.

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.

Parameters:
Name Type Argument Default Description
x number

The horizontal scroll factor of this Game Object.

y number <optional>
x

The vertical scroll factor of this Game Object. If not set it will use the x value.

Since: 3.0.0
Source: src/gameobjects/components/ScrollFactor.js (Line 64)
Returns:

This Game Object instance.

Type
Phaser.GameObjects.Components.ScrollFactor