Skip to content

Instantly share code, notes, and snippets.

@EduardoLopes
Created December 10, 2015 14:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save EduardoLopes/8c835698586bd275e81e to your computer and use it in GitHub Desktop.
Save EduardoLopes/8c835698586bd275e81e to your computer and use it in GitHub Desktop.
Luxe Pixel Perfect camera scale
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