- Title: Adapt game resolution
- Description: Change the view size to whatever screen resolution the player is using.
- GM Version:
- Registered: not sure but I dont think so.
- File Type: .gmk
- File Size: 43 KB
- File Link: Yoyogames link
I used this technique for my Nyan Cat Screensaver. (this example is actually an early version of that screensaver).
Use this for your game if:
- Your game runs in full-screen mode
- if it doesn't matter how far the player can see
To solve this problem and make it look good, no matter which screen resolution the computer it is played on has, you need a few lines of code and set game settings correctly. Download the .gmk example and read the below steps. These steps are included in the help file of the .gmk.
Step one - Game Settings:
- In Game Maker, Click "Resources / Change Global Game Settings".
- Check the box "Start in full-screen mode".
- Just underneath that, check the circle "Fixed Scale (in %):" and set the value to "100".
- Click OK.
Step Two - setting up a room correctly:
- Create a room
- Set room width and height to something like 3000x3000. The view size will never be larger than the room size, so if you have a room size of 640x480, the view size will never be larger than 640x480 (a border will in that case appear, but in those cases you will most likely want to run the game in a window).
- Go to the "View" tab in the room.
- Make sure both "Enable use of views" and "Visible when room starts" is NOT CHECKED! both should be empty.
Step three - The coding:
- Create a new object, name it something like obj_viewController
- In any one-time event (like Create,Room/Game start, key press/release, and NOT step or Keyboard), add the script below. You are most likely to use the room
start or create event, or an event that toggles full-screen mode.
view_wview = display_get_width(); view_hview = display_get_height(); view_wport = display_get_width(); view_hport = display_get_height(); view_enabled = 1; view_visible = 1;
Now it is all done! Your game view will change according to the player's screen resolution! It will never look wierd or stretched.
Play your game and see for yourself!
Edited by Pandaboy, 26 July 2012 - 01:44 AM.