Screen width and height
I think there was a thread about this, but I am just wondering how do I know the screen width, height when it is constantly changing.
I think there was a thread about this, but I am just wondering how do I know the screen width, height when it is constantly changing.
Let me argue that the screen size in microStudio is more consistent than in most other 2D game engines :-) ... and actually never changing! But I understand how puzzling it can be if you were used to working with physical screen coordinates before.
Consider that people who will play your game will have different screen resolutions, 1024x768, HD, full HD, full HD+, 4K, 3440x1440, whatever... In many 2D engines, if you want to support any screen resolution, you will have to deal with that all by yourself: compute the correct scaling ratio for all your sprites, figure out the coordinates of the center of the screen...
microStudio takes care of all this for you and pre-scales the screen space, ensuring that your game will look the same on any screen. There are actually two cases:
This way, if you choose to display a sprite with a size of 20x20 (screen.drawSprite("mysprite",x,y,20,20)
), it will always look of the same size, relatively to the size to the full game window. Consider the game below, launch it and resize the window, even to extremely flat landscape mode or very thin portrait mode, you will see that it can be played on really any screen... and we didn't even have to care about it when writing the code:
https://microstudio.io/gilles/fishing2/
Of course it cannot be all perfect:
The coordinates system is explained in the documentation, section Function Reference / Display (screen)
Thank you this is helpful as I didn't know I can force a screen resolution.
Is it possible to be signaled when the screen size has changed as a result of being resized? Or do I regularly check the current screen object values for that? My game needs to redraw the screen if it has changed, otherwise it goes black when resized.
UPDATED
Checking the screen values for changes does work quite well.