how do I detect screen size?

I kind of want to make a game that detects the screen size and sets the stage size to the screen size, but I don't know anything about javascript, so can you show me the code?

That's what presentation mode is for!

But here you go:


I know about presentation mode., but I want it to detect window/screen size.

Use ( [width] of [Stage] ) and ( [height] of [Stage] )

( [right] of [Stage] ) and ( [top] of [Stage] ) if you want half of it

If you wanna scale based on the screen size:
( [left] of [Stage] ) + ( [width] of [Stage] ) * percent
( [bottom] of [Stage] ) + ( [height] of [Stage] ) * percent

As for setting the size of the stage, I don't really know aside from just using fullscreen.
Afaik, you could use fractional values on the screen so the resolution shouldn't really matter.

the height of the screen minus OS UI features (toolbars, etc.)

the width of the screen minus OS UI features (toolbars, etc.)

the height of the entire screen

the width of the entire screen

thank you.

ok, now, I want a block that puts the tab in fullscreen, can anyone help?

Hi everybody!

  1. First of all, note that Snap! has the library "Provide getters and setters for all GUI-controlled global settings" that allows you to program any Snap! thing. You can programmatically change to presentation mode, change stage size...

  2. With this, and @snapenilk JS solutions, you can adjust your stage size to the screen size.

  3. Manage your browser from Snap! is possible... but it is not a Snap! question, it is a JS one. You will find a lot of info about this... but maybe this is not the place (or we can move it to Advanced Topics cat). A clue: `document.documentElement.requestFullscreen()' will be your function, but you will have to create a JS event because browsers (and I) want to protect users.


ok, and I already knew about the library, that's why I didn't ask for a block to set the stage size.