Last active
July 8, 2019 09:41
-
-
Save RockinPaul/e212a7d3a6b8f4f2283c87848584736d to your computer and use it in GitHub Desktop.
This scaling solution gives a "best fit", and can easily be adapted to suit your own base game resolution.
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
// Note that you can call this code in a script | |
// so that you can simply call the script at the start of each room. | |
// You can even add a final piece of code to have this | |
// automatically set all the views in all your rooms | |
// so that you only need to call it once at the start of the game. | |
// This code will just loop through every room in your game, destroy the default camera, | |
// and then create a new camera that is correct for the display size and aspect ratio, | |
// as well as enable a viewport in the room for the camera to act on. | |
var _check = true; | |
var _rm = room_next(room); | |
var _rprev = _rm; | |
while (_check = true) | |
{ | |
var _cam = room_get_camera(_rm, 0); | |
camera_destroy(_cam); | |
var _newcam = camera_create_view((1024 - VIEW_WIDTH) div 2, (768 - VIEW_HEIGHT) div 2, VIEW_WIDTH, VIEW_HEIGHT); | |
room_set_camera(_rm, 0, _newcam); | |
room_set_viewport(_rm, 0, true, 0, 0, VIEW_WIDTH, VIEW_HEIGHT); | |
room_set_view_enabled(_rm, true); | |
if _rm = room_last | |
{ | |
_check = false; | |
} | |
else | |
{ | |
_rprev = _rm; | |
_rm = room_next(_rprev); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment