Navigation
These archived docs are for Phaser 2.4.4 Phaser 3 docs can be found on newdocs.phaser.io.
Phaser CE docs can be found on the Phaser CE Documentation site.

Constructor

Phaser.Component. ScaleMinMax

new ScaleMinMax()

The ScaleMinMax component allows a Game Object to limit how far it can be scaled by its parent.

Source code: gameobjects/components/ScaleMinMax.js (Line 12)

Public Properties

scaleMax : Phaser.Point

The maximum scale this Game Object will scale up to.

It allows you to prevent a parent from scaling this Game Object higher than the given value.

Set it to null to remove the limit.

Source code: gameobjects/components/ScaleMinMax.js (Line 46)

scaleMin : Phaser.Point

The minimum scale this Game Object will scale down to.

It allows you to prevent a parent from scaling this Game Object lower than the given value.

Set it to null to remove the limit.

Source code: gameobjects/components/ScaleMinMax.js (Line 36)

transformCallback : Function

The callback that will apply any scale limiting to the worldTransform.

Source code: gameobjects/components/ScaleMinMax.js (Line 20)

transformCallbackContext : Object

The context under which transformCallback is called.

Source code: gameobjects/components/ScaleMinMax.js (Line 26)

Public Methods

setScaleMinMax(minX, minY, maxX, maxY)

Sets the scaleMin and scaleMax values. These values are used to limit how far this Game Object will scale based on its parent.

For example if this Game Object has a minScale value of 1 and its parent has a scale value of 0.5, the 0.5 will be ignored and the scale value of 1 will be used, as the parents scale is lower than the minimum scale this Game Object should adhere to.

By setting these values you can carefully control how Game Objects deal with responsive scaling.

If only one parameter is given then that value will be used for both scaleMin and scaleMax: setScaleMinMax(1) = scaleMin.x, scaleMin.y, scaleMax.x and scaleMax.y all = 1

If only two parameters are given the first is set as scaleMin.x and y and the second as scaleMax.x and y: setScaleMinMax(0.5, 2) = scaleMin.x and y = 0.5 and scaleMax.x and y = 2

If you wish to set scaleMin with different values for x and y then either modify Game Object.scaleMin directly, or pass null for the maxX and maxY parameters.

Call setScaleMinMax(null) to clear all previously set values.

Parameters
Name Type Description
minX number | null

The minimum horizontal scale value this Game Object can scale down to.

minY number | null

The minimum vertical scale value this Game Object can scale down to.

maxX number | null

The maximum horizontal scale value this Game Object can scale up to.

maxY number | null

The maximum vertical scale value this Game Object can scale up to.

Source code: gameobjects/components/ScaleMinMax.js (Line 110)