malgin

Proper way to scale a game in Phaser 3

Recommended Posts

Hello, community!

I've just started using Phaser 3, and it's a pleasant experience. Special thanks to team for TypeScript definitions.

I'm currently trying to implement scale logic for my game. I've read in this blog post that developers considered to change `ScaleManager` in Phaser 3, but I didn't find one in sources.
I've also tried to take a look at how resize is handler in Mario platformer from pinned topic. Author used this:

scaleMode: 0, //Phaser.ScaleManager.EXACT_FIT,

... but I didn't find `scaleMode` in Config.js object, and also didn't find any reference in Game.js object to this config property. It seems this was a way to scale game in Phaser 2, but not anymore.

My current idea is to put all game objects in a 'parent' frame (not sure which object should I used for this btw..), and scale this 'frame' in each Scene on 'resize' event. This feels awkwardly wrong to me, and I'm looking for better approach.

Would be very grateful for a hint where to look, or an advise on how to properly implement scaling.

Thank you!

Share this post


Link to post
Share on other sites

The Mario example was made mainly while Phaser 3 was in beta and much by trail and error. That line should be removed because it does nothing (I found 

https://codepen.io/samme/pen/JMVBeV and tried it in my game with no success). I should really sit down and clean up the source.
 
I ended up making a custom method to scale the whole canvas.

Share this post


Link to post
Share on other sites

Hi guys, I've been trying to properly scale my game, any luck with a built-in solution from Phaser, or do we have to manually resize and position all the Game Objects ourselves?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.