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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.