0 Favourites

WindowWidth/WindowHeight and scaling

  • 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?

    <img src="http://i.imgur.com/qwrnriP.png" border="0">

    SpaceGame.capx

  • Instead of windowHeight/width try layoutHeight/Width. After a quick test it worked for me. Window size can be bigger than layout size.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • 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.

  • 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.

    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.

  • 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.

  • 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")).

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
43 2,266
Zebbi's avatar
Zebbi
Unread hot topic
36 1,131
Zebbi's avatar
Zebbi
Unread hot topic
0 Favourites
Scale Behavior
35 2,678
Mipey's avatar
Mipey