Created
January 5, 2017 15:46
-
-
Save iCodeForBananas/5860f5cf5915d1bc3c39e3f2fcf3eef9 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
import GameConsts from 'lib/GameConsts' | |
export default function() { | |
const state = this.game.store.getState() | |
const scaleFactor = state.player.quality <= GameConsts.MAX_QUALITY_SIZE | |
? state.player.quality | |
: GameConsts.MAX_QUALITY_SIZE | |
const innerWidth = window.innerWidth | |
const innerHeight = window.innerHeight | |
// scaleFactor === 950 | |
let gameRatio = innerWidth / innerHeight | |
let widthScaleFactor = Math.ceil(scaleFactor * gameRatio) | |
let heightScaleFactor = scaleFactor | |
// gameRatio 5.644117647058824 widthScaleFactor 5362 heightScaleFactor 950 | |
console.log('gameRatio', gameRatio, 'widthScaleFactor', widthScaleFactor, 'heightScaleFactor', heightScaleFactor) | |
if (widthScaleFactor <= 0.5) widthScaleFactor = 0.5 | |
if (heightScaleFactor <= 0.5) heightScaleFactor = 0.5 | |
this.game.scale.setGameSize(widthScaleFactor, heightScaleFactor) | |
RS.tiles && RS.tiles.resize(widthScaleFactor, heightScaleFactor) | |
// $("#ui-app").css({ | |
// transform: "scale(" + Math.min(innerWidth / 1100, 1) + ")", | |
// "transform-origin": "top right", | |
// }) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment