NW.js object and window sizes

Get help using Construct 2

Post » Wed May 20, 2015 2:50 pm

Is there a way to set the window width and height with the NW.js object independent of window border width and height? I need pixel-perfect sizes for window modes and it's hard to get it right when I need to take the window borders into account. Do they even stay the same pixel size for different OS'es?
B
39
S
16
G
6
Posts: 543
Reputation: 7,619

Post » Fri May 22, 2015 1:20 pm

Hey @ErekT, :)

One way is to, at the start of the layout, get the difference between NWjs's OUTER window measurements and C2's INNER window (canvas) measurements.
Save the resulting values in two global variabls.

osWindowMarginWidth
osWindowMarginHeight


Then when you set the window's OUTER size via the NWjs actions, give the INNER pixel size you want, plus the extra margin size you stored in the global variables earlier.


I've included a commented example capx showing the solution in action.
Download example capx
(In the capx, you can press "1" or "2" on the keyboard to set either the OUTER or INNER window size to 256 x 256.)
B
28
S
18
G
8
Posts: 332
Reputation: 6,191

Post » Fri May 22, 2015 1:51 pm

Oh that works great! Thanks so much for the help :)
B
39
S
16
G
6
Posts: 543
Reputation: 7,619

Post » Fri May 22, 2015 1:55 pm

No problem :)
B
28
S
18
G
8
Posts: 332
Reputation: 6,191


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 21 guests