WindowHeight - self.Height not centering n Stretch

0 favourites
  • 4 posts
  • Sorry guys... my Capx is 60MB. (Msg me Ashley if you want it. I can upload it to my FTP for you if need be.) I am rolled back to r90 right now and not too worried about this. This was mainly a courtesy FYI

    In r90 I used FullScreen on scale mode in r90 with success. I did not updated to r91,or r92. I did update to r93 today. I noticed it was a little better performance. The one observation I made is that in r93. The stretch(on scale) video mode causes my menu images that used to be centered in r90 to be down and to the right. The primary trick I used in r90 to center was (WindowHeight - self.Height) When it comes to r93, It will not scale with the on scale... or what is now called stretch. The other modes seem to be fine... but it looks like the ability to use (WindowHeight) & (WindowWidth) broke in r93

    Here are some code examples of what I was doing to center my custom built menus. However, you can duplicate this easily by centering an image every tick in r90/r93 with the following "Heuristic"

    I made a menu that was an image put in the middle of the screen with an "Set Position" every tick.

    Menu Background image used to be set up like this:

    New X Co-Ordinate in Pixels:

    ((WindowWidth - self.Width)/2) + 400

    New Y Co-Ordinate in Pixels:

    ((WindowHeight - self.Height)/2) + 300

    Cursor was setup like this:

    New X Co-Ordinate in Pixels:

    ((WindowWidth - self.Width)/2) + (400 - 419 - 52) + (52 * CursorX)

    New Y Co-Ordinate in Pixels:

    ((WindowHeight - self.Height)/2) + (300 - 483 -52) + (52 * CursorY)

    I would Create menu items dynamically like this:

    Create object    Inventory_HUD2 on layer "HUD" at ((WindowWidth - Menu.Width)/2) + (52*(MenuArray.CurY+1)) +304, ((WindowHeight - Menu.Height)/2) + (52*(MenuArray.CurX+1)) + 40

    If I use r93 and run the game and pull up the menu and start playing around with the windows size it scales funny until I scale it down to the default unstreched size of 800 x 600.

    I love Construct! Keep up the good work guys!


    Windows XP SP3 (Confirmed on my Windows 7 box too)

    AMD Radeon HD 6670 w/ Latest Driver

    4GB Corsair RAM

    Tested with both:

    Chrome 19.0.1084.52

    Firefox Aurora

  • This is by design: due to a breaking change to fix a bug in parallaxing, you can't use WindowWidth/2 and WindowHeight/2 to refer to the middle of the screen any more. The new correct way to do this is the new viewport system expressions:

    (ViewportLeft("Layer") + ViewportRight("Layer")) / 2

    (ViewportTop("Layer") + ViewportBottom("Layer")) / 2

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Perfect. That worked. Thanks.

  • I'm going to try it too. Have the same issue with centering.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)