docking while the program is running
-
Are we talking about your running program or Fuze itself? Because you have to handle the scaling and docked / undocked yourself.
If it's Fuze then that could be a bug
-
only the program, and yea that makes sense, better to document it than not i guess
-
Here's the help page for the 'docked' command / function:
-
If you want to simplify things, you can set the screen mode to 1280x720. That way, docked and undocked mode in your program will use the same screen resolution.
It's an easy approach, but you'll obviously loose the high resolution in docked mode using that method.
-
^^^ @Nisse5 's suggestion will absolutely work. You can do setMode(1280, 720) to force the docked resolution into the same as handheld. This will get rid of the scaling issue.
Another way is to have screen dimension variables which are calculated every frame in your main loop. This sounds taxing, but it really isnt:
loop clear() screen = { gwidth(), gheight() } // Now we have screen.x and screen.y being calculated in the loop, giving us the correct resolution all the time if we use these screen variables in our program update() repeat
Probably simpler to use setMode(), but this way you get to keep the crisp 1920 x 1080 res in TV mode.
-
@Dave One drawback of using gWidth()/gHeight() is that the code might get a bit unnecessarily complicated to code, since Nintendo Switch basically just have 2 resolutions (one portable resolution and one docked resolution), and these resolutions are predictable from the programmer's standpoint. It's not like on the PC, where the user might use all kinds of crazy screen resolutions.
My approach in my current project (keeping 1080p docked and 720p undocked) is to hardcode the layout info using a struct.
Something like this:// Define the hardcoded layout "constants" at the initialization of the program // Default values for docked mode, // but use it for undocked as well! struct LayoutCoordsStruct vector point1 = {100, 80} // And so on... endstruct LayoutCoordsStruct DockedLayout // *** Set the undocked layout "constants" here, overriding the defaults LayoutCoordsStruct UndockedLayout UndockedLayout.point1 = {80, 70} // Now, in the actually running code, use the "docked()" within // the update loop to determine what kind of layout that // should be used layout = UndockedLayout if docked() then layout = DockedLayout endif // The coordinates in "layout" will now refer to the correct // view, and is ready to be used! print(layout.point1)
-
Now I have a issue with docked, my game was fine before now only plays handheld
Comes up with draw sheet scale to large -
@waldron Put
setMode(1920,1080)
at the start of your program. Very first line! Should sort you out here. -
For those who had it the other way around: I used
setMode(1920,1080)
on top of my program and had a text line (drawn with drawMulticoloredText) at the bottom.- When I undocked during the game the line was not shown anymore --> of course because the display has 1280x720
- When I redocked everything was ok
What helped was applying thesetMode(1920,1080)
command always if the docking or undocking was happening inside the main loop.
It lacks now a bit of performance in undocked (50fps instead of 62fps, not sure if my debug routine is very accurate, if these values are not real-fps but loop counts), but looks nicer.
Maybe I read that performance note already here somewhere. ;-)
..ah forgot a code sample:
setMode(1920, 1080) _lastDockedStated = docked() loop clear() if (_lastDockedState != docked()) then setMode(1920, 1080) _lastDockedStated = docked() endif // main game code update() repeat
-
So, here's what I did in the last program that I implemented this on...
First up, everything is scaled by a scale factor.
I have a struct called 'g' which holds game state - standard variables will suffice and will actually be quicker - speed was not important to me in this program.
function reScale() g.width = gWidth() g.scale = g.width / 1280 // Various other stuff that has to be resized by g.scale return void // Main loop loop clear() if g.width != gWidth() then reScale() endif // Do stuff update() repeat
Never mind docked / undocked, ignore them and just look at the width. Simples...