WindowWidth/WindowHeight and scaling

Get help using Construct 2

Post » Wed Mar 20, 2013 2:04 am

How do these work with scaling?

Sometimes I have enemies spawn off the screen. The enemy spawning code has them spawn at x = either 10 or WindowWidth - 10, and y = either 10 or WindowHeight - 10.

There is also code that move them to some amount if they are within 50 pixels of the player object, to prevent them from spawning too close to the player. However, this code is not the problem, as I have enemies spawning off the screen (which makes them unkillable) as the player is sitting directly in the middle of the screen.

In addition, enemy ships have the wrap and destroy-outside-layout properties, neither of which appear to work. In other words, if you activate shields and crash into an enemy, it does not wrap, it just flies off the screen and disappears forever without actually being blown up because the counter tracking the number of enemies left does not decrease.

Can anyone shed some light on this?



SpaceGame.capx
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,194

Post » Wed Mar 20, 2013 7:14 am

Instead of windowHeight/width try layoutHeight/Width. After a quick test it worked for me. Window size can be bigger than layout size.
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Wed Mar 20, 2013 7:43 am

vee, I should just hire you to be my personal Construct 2 teacher.

This still bugs me, because I really shouldn't have to change it to LayoutWidth. WindowWidth should be working, and I'm not sure why it's buggy.Excal2013-03-20 07:47:02
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,194

Post » Wed Mar 20, 2013 7:57 am

[QUOTE=Excal] vee, I should just hire you to be my personal Construct 2 teacher.

This still bugs me, because I really shouldn't have to change it to LayoutWidth. WindowWidth should be working, and I'm not sure why it's buggy.[/QUOTE]

Heh :)

This is my assumption, haven't seen any official on this: LayoutWidth is the width you define in the game, it does not change with scaling or other properties. WindowWidth on other hand can change depending on monitor, your layout is scaled to fit windowWidth. But layout with width of 1000 is still 1000 pixels wide, no matter what your indowWidth is.
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Wed Mar 20, 2013 8:56 am

Switching to layout width instead of window width now makes the wrap behavior work. I wonder if anyone else has had issues with window size and objects spawning off the screen.
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,194

Post » Wed Mar 20, 2013 3:38 pm

Don't confuse the window size and the viewport size.

If you zoom in or out, or scale using the 'fullscreen' options, the window size does not change. Instead, the viewport changes.

So where you use WindowWidth, you probably mean to use (ViewportRight("layer") - ViewportLeft("layer")).
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Wed Mar 20, 2013 7:22 pm

Ah, this makes sense.

For purposes of improvement, I think the difference between window size and viewport could be better clarified in the manual because I read through that and was convinced that viewport is not what I wanted to use, but window size instead.
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,194


Return to How do I....?

Who is online

Users browsing this forum: makotto, randomly, Walessio and 25 guests