start fullscreen, resolution, aspect, exit game?

Get help using Construct 2

Post » Fri Mar 01, 2013 4:08 pm

I want to create game that can:
1) Start in fullscreen (and hide cursor, as well as start in specified resolution, instead of using desktop resolution only)
2) Can switch resolution in-game
3) Can enumerate list of available system resolutions, instead of
using hardcoded list
4) Can store resolution settings in config (ini) or registry and start next time in saved resolution
5) Can switch to windowed mode and back with standard ALT+WIN (or browser standard F11) or in-game menu item.
6) Can keep proper aspect ratio in any fullscreen resolution, as well as any windowed mode including user stretched mode (i wish window to autocorrect ver and hor resolution as same time user resizing it, to keep aspect ratio)
7) Can have at least 3 UI presets for 4:3, 16:9 and 16:10 displays and switch to them automaticaly according to current resolution aspect ratio.
Or at least fixed 16:9 in every aspect, with no funny glitches.
8) Can exit fullscreen game with menu item "exit" in addition to Alt+F4 or X button in window.
9) Can do all of above on every posible exported platform\format (all node-webkit wrappers for linux, osx and windows are minimum i need).

How can i achive that with Constuct 2? I dont see any in editor options for that!

A the moment i only managed to launch node-webkit in fullscreen by editing \Construct 2\exporters\html5\node-webkit\package.json and adding

"fullscreen": true,

in window section. But it only allows to launch game in same resolution as desktop have now, and it upscales layout by keeping fixed horizontal aspect, vertical aspect meanwhile gets bigger, if im going from wider 16:9 to no so wider 16:10 or 4:3, if i go to anything wider than 16:9, then vertical aspect is fixed, but foreground level element with paralax set to 100 goes beyond layout and appears above black bars, while fixed background covers only 16:9 area.
As for rest - im almost out of ideas!

Im thinking about using javascript window.close() as function for exit button or using this for closing, changing resolution, switching to windowed and fullscreen, but i have no idea where in Construct 2 i should put these js functions to be called whenever button pressed in game.
Well, im thinking about ugly hack - manually editing html file after export and adding some overlay above game with exit button that call these JS functions, but thats a lot of extra work and really ugly, comparing to native in-game expirience.

Also i would like to auto pause game on unfocused or minimized window or during using, but yet have no idea how to make it in Constuct 2.

Can anyone please give some tips, share portions of code from your games that would do this, or maybe Scirra guys can add these features to their TO-DO list (and with high priority, because its one of the must have features that Constuct 2 really needs ASAP) so that in near features that would be built-in and can be done easy way?

P.S. - I can do most of that in flash with some projectors like Zinc with no problem, but here its a real problem!
Posts: 5
Reputation: 616

Post » Fri Mar 01, 2013 6:39 pm

Use the Browser object's 'Request fullscreen' and 'Cancel fullscreen' actions. You can request fullscreen on startup with node-webkit. The Browser 'close' action should also exit (although there's a bug about that sometimes crashing that is being investigated). C2 automatically pauses the game when minimized (or invisible, like switching to another tab in a browser).

Generally I think it's best to avoid messing with the user's resolution - 2D games can run fullscreen just fine on most computers.
Scirra Founder
Posts: 22,949
Reputation: 178,544

Post » Thu Aug 15, 2013 2:00 pm


Yes it's possible to edit the package.json to launch nw with fullscreen or kiosk mode set to "true" ... but in this case the project is launch with a fullscreen WHITE window and seems also spend time doing this.

It's far better to use the C2 specific "loader" system and request a fullscreen at start using a empty "black" layer and then "go to" your layout when the loader system is completed (this should be instant unless in preview mode).
Posts: 298
Reputation: 5,240

Post » Fri Dec 13, 2013 1:21 pm

[QUOTE=Ashley]You can request fullscreen on startup with node-webkit.[/QUOTE]
Unfortunately there is only option to maximize the window. When I export to EXE with node-webkit, after maximizing the game it still has the top bar and the bottom bar (with tray and opened apps).tecbug2013-12-13 13:22:20
Posts: 282
Reputation: 7,578

Post » Fri Dec 13, 2013 1:37 pm


Use the browser object.. request full screen.
Posts: 1,096
Reputation: 11,013

Post » Fri Dec 13, 2013 8:29 pm

It works :)
Posts: 282
Reputation: 7,578

Return to How do I....?

Who is online

Users browsing this forum: heliogame, Vodakman and 27 guests