Center window after resize (solved)

Get help using Construct 2

Post » Tue Sep 03, 2013 6:39 pm

Is there any way to retrieve the user's screen size to position the window after re-sizing using the node-webkit object? I tried re-positioning it based on the difference between the old window size and new window size, but it's kind of messy and I couldn't get it completely right.MadFactory2013-09-03 22:40:00
Image
B
242
S
29
G
13
Posts: 1,787
Reputation: 18,685

Post » Tue Sep 03, 2013 8:37 pm

Theres 2 new expressions in the new beta update (r143) which are ScreenWidth and ScreenHeight I haven't experimented with it so I'm not sure if the windows hotspot is top left or center but try these:

For Top-Left Hotspot: Set Window.X to (ScreenWidth / 2) - (WindowWidth / 2)

For Center Hotspot: Set Window.X to ScreenWidth / 2

Then repeat for Y/Height
B
46
S
14
G
7
Posts: 603
Reputation: 8,096

Post » Tue Sep 03, 2013 9:15 pm

Yeah I'm not seeing those anywhere...r143.
Image
B
242
S
29
G
13
Posts: 1,787
Reputation: 18,685

Post » Tue Sep 03, 2013 9:24 pm

Oops. ScreenWidth and ScreenHeight are Browser expressions.
B
46
S
14
G
7
Posts: 603
Reputation: 8,096

Post » Tue Sep 03, 2013 9:40 pm

Oh! Perfect.
Image
B
242
S
29
G
13
Posts: 1,787
Reputation: 18,685

Post » Tue Sep 03, 2013 10:07 pm

Hmm. For some reason the window is not being centered vertically. I made an example .capx here.
Just drag the window around and press 1 or 2 to scale/position it.

Any ideas? Bug?MadFactory2013-09-03 22:10:42
Image
B
242
S
29
G
13
Posts: 1,787
Reputation: 18,685

Post » Tue Sep 03, 2013 10:29 pm

It's centering for me perfectly fine.
B
46
S
14
G
7
Posts: 603
Reputation: 8,096

Post » Tue Sep 03, 2013 10:32 pm

Try rounding the y value. It doesn't seem to like decimal numbers.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,630

Post » Tue Sep 03, 2013 10:38 pm

Aha! Thanks, works perfectly now.
Image
B
242
S
29
G
13
Posts: 1,787
Reputation: 18,685


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot] and 9 guests