Last active
February 2, 2022 16:10
-
-
Save osbulbul/7727ed4ac99044cc12ad1c8c3157e11c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Lib | |
| import Phaser from "phaser"; | |
| //Scenes | |
| import playGame from "./playGame"; | |
| //Find the perfect ratio | |
| let width = 720; | |
| let height = 1280; | |
| let perfectRatio = width / height; | |
| //Find the current screen ratio | |
| let innerWidth = window.innerWidth; | |
| let innerHeight = window.innerHeight; | |
| let actualRatio = innerWidth / innerHeight; | |
| //Find the final width | |
| width = Math.min(width*actualRatio/perfectRatio, 1280); | |
| let gameConfig = { | |
| type: Phaser.AUTO, | |
| scale: { | |
| mode: Phaser.Scale.FIT, | |
| autoCenter: Phaser.Scale.CENTER_BOTH, | |
| parent: 'jumpingbox', | |
| width: width, | |
| height: height | |
| }, | |
| physics: { | |
| default: 'arcade', | |
| matter: { | |
| gravity: {x:0, y:500}, | |
| debug: true | |
| } | |
| }, | |
| scene: playGame | |
| }; | |
| let game = new Phaser.Game(gameConfig); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment