This means our actual render results are at 800×600 ( or whatever resolution you specified ). While in Viewport, the results are actually scaled down to the resolution specified. In viewport set to 2D, the width and height are used and the results are simply scaled up (or down) to match the resolution of the actual device. When viewport is set to disabled, the width/height are ignored completely and the resolution of the device is used. It’s the ultimate results that make the difference. Resolution is 1600×900 ( my native resolution ) and display resolution settings ignored. The Viewport setting has a profound effect on the results. The following screenshots are all scaled down but maintain the aspect ratio of the source image. The following display settings are very important. Here is a run, using default settings on my laptop which has a 1600×900 display. The actual image is 1920×1080 in size, so it should show us the results that various settings have on our game. Now to illustrate how resolution works in Godot, I’ve created a Sprite Node( not centered, at 0,0 ) using this image, which illustrates the various screen resolutions. Please note there are two check boxes to enable! First you need to enable the fullscreen setting, then you need to turn it on. You can accomplish the exact same thing (much easier) using project settings, like so: There is also an event handler connected to fire when the resolution changes, we simple print the resolution to the console when it changes. Due to the app going full screen, it is no longer easy to close the window, so I’ve also wired in some code to handle shutting down if the user hits Esc. Of course this code does a lot more than just set the application full screen. #Input handler, listen for ESC to exit app This is a script, derived from node, that gets run automatically when your game launches. To do it with code, create a new autoload script as described here. It’s possible to set your application to run full screen, both using code or in the application settings. On the other hand, you can create more viewports within the scene as we will see later. So, no matter how you create your scene, you will always have at least one viewport. In that node if you run the code: func _ready(): One very important thing to understand is, the very root of your scene, the node that owns all of the nodes in a scene, is ultimately a viewport. Please note, the full screen portions didn’t display properly in the video. There is a 1080p version of this tutorial available here.
0 Comments
Leave a Reply. |