DEVOLOGIST</>

Scaling Game Objects in Phaser 4

Phaser
01/08/20266 min read

Scaling game objects is the process of making them appear larger or smaller on the screen without changing the original asset file. In Phaser 4, scaling is essential for building responsive UIs, adjusting character size, and making assets fit different layouts.

If positioning decides where an object appears, scaling decides how big it appears.

What Is Scaling?

A game object has a visual size on screen. With scaling, you multiply that size.

Basic Scaling Example

create() {
const player = this.add.image(400, 300, 'player');
player.setScale(0.8);
}

Using setScale()

The most common way to scale game objects is with setScale().

this.add.image(200, 200, 'logo').setScale(1.5);

Why setScale() is useful

Scaling Horizontally and Vertically

If you want different scaling on each axis, Phaser allows separate values.

this.add.image(200, 200, 'box').setScale(2, 1);

This makes the object twice as wide but keeps the original height.

Scaling Text

Text can also be scaled, which is very useful for UI headings:

this.add.text(400, 100, 'Game Over', {
fontSize: '32px',
color: '#ffffff'
}).setOrigin(0.5).setScale(1.5);

Scaling and Origin

Scaling happens around the object’s origin. That means if you scale an image, it grows or shrinks relative to its origin point. If the origin is not set properly, scaling may look off-center.

Best Practices

Common Mistakes

  1. Stretching unintentionally: Mixing X and Y scale values.
  2. Scaling low-quality assets: Causes blurriness.
  3. Forgetting about origin: Makes objects grow in the wrong direction.

Conclusion

Scaling game objects in Phaser 4 is a simple but powerful technique. Once you master setScale(), you can make your scenes feel much more polished and flexible.

Quick Snippet

const sprite = this.add.image(300, 300, 'enemy');
sprite.setScale(0.6);