Phaser API Documentation

  Version: 
updateCenter()

Description:

Calculates and updates the canvas CSS style in order to center it within the bounds of its parent. If you have explicitly set parent to be null in your game config then this method will likely give incorrect results unless you have called the setParentSize method first.

It works by modifying the canvas CSS marginLeft and marginTop properties.

If they have already been set by your own style sheet, or code, this will overwrite them.

To prevent the Scale Manager from centering the canvas, either do not set the autoCenter property in your game config, or make sure it is set to NO_CENTER.

Since: 3.16.0