Created
December 10, 2015 14:21
-
-
Save EduardoLopes/8c835698586bd275e81e to your computer and use it in GitHub Desktop.
Luxe Pixel Perfect camera scale
This file contains 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
override function onwindowsized( e:WindowEvent ):Void { | |
zoomRatio.x = Math.floor(Luxe.screen.w / gameResolution.x); | |
zoomRatio.y = Math.floor(Luxe.screen.h / gameResolution.y); | |
//get the smallest zoom ratio between zoomRatio.x and zoomRatio.y, and limit it to be greater or equal 1 | |
zoom = Math.floor(Math.max(1, Math.min(zoomRatio.x, zoomRatio.y))); | |
var width = gameResolution.x * zoom; | |
var height = gameResolution.y * zoom; | |
var x = (Luxe.screen.w / 2) - (width / 2); | |
var y = (Luxe.screen.h / 2) - (height / 2); | |
Luxe.camera.viewport.set(x, y, width, height); | |
backgroundBatcherCamera.viewport.set(x, y, width, height); | |
foregroundBatcherCamera.viewport.set(x, y, width, height); | |
//update some stuff used in the cammera follower component | |
Luxe.camera.get('follower').onWindowResized(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment