[CAPX INCLUDED] Scale layer to window size/viewport width?

0 favourites
From the Asset Store
Get Ready for the New Wave of "Bottom Screen" Games!
  • > Setting the scale of the layer to such an enormously high number isn't what you are after..

    > If you set the width of the bar to viewportright()-viewportleft(), however..

    >

    Yes, that would work, but I need not just that bar but the other items on the layer resized too, all of the score and life and health numbers. 1.3 isn't enormously high for a layer scale, it's only a third(ish) bigger. Can I scale a whole group of items so they're exactly the same relative size? If not, that's why I wanted to use a dynamic layer scale figure depending on the resolution of the players screen.

    Why would you use layer scale?

    Everything does get scaled automatically..

    You didn't want to scale the bar, you wanted to stretch it, that's the difference..

  • >

    > > Setting the scale of the layer to such an enormously high number isn't what you are after..

    > > If you set the width of the bar to viewportright()-viewportleft(), however..

    > >

    > Yes, that would work, but I need not just that bar but the other items on the layer resized too, all of the score and life and health numbers. 1.3 isn't enormously high for a layer scale, it's only a third(ish) bigger. Can I scale a whole group of items so they're exactly the same relative size? If not, that's why I wanted to use a dynamic layer scale figure depending on the resolution of the players screen.

    >

    Why would you use layer scale?

    Everything does get scaled automatically..

    You didn't want to scale the bar, you wanted to stretch it, that's the difference..

    LittleStain No, I want to scale it, retaining the correct height as well for the bar, I could mock up the bar with some counters and text on it to make it appear more like an HUD if you need? If I stretch the bar, it would look odd when it has HUD items on it, and I would need to get those stretched too, which is why I need it scaling to the right width whilst retaining the correct height. I need the correct height to be retained when the width is met with the side of the screen. I can't see why scaling the layer would be the wrong way of doing this?

  • Is there really a reason to re-invent the wheel?

    The right combination of the anchor behaviour with paralax 0,0 works with any fullscreen setting..

    https://dl.dropboxusercontent.com/u/485 ... nchor.capx

  • Is there really a reason to re-invent the wheel?

    The right combination of the anchor behaviour with paralax 0,0 works with any fullscreen setting..

    https://dl.dropboxusercontent.com/u/485 ... nchor.capx

    LittleStain Thanks for the example, here's a new one with a mockup HUD for this exercise, https://www.dropbox.com/s/g4curnknsl789 ... .capx?dl=0 - if you press S to change the scaling, you'll notice it's not wide enough. I doubt I could use anchors to keep everything correctly sized on that change of scaling for this type of HUD?

  • > Is there really a reason to re-invent the wheel?

    > The right combination of the anchor behaviour with paralax 0,0 works with any fullscreen setting..

    >

    > https://dl.dropboxusercontent.com/u/485 ... nchor.capx

    >

    LittleStain Thanks for the example, here's a new one with a mockup HUD for this exercise, https://www.dropbox.com/s/g4curnknsl789 ... .capx?dl=0 - if you press S to change the scaling, you'll notice it's not wide enough. I doubt I could use anchors to keep everything correctly sized on that change of scaling for this type of HUD?

    I doubt you could too..

    I don't doubt it could be done, though..

  • >

    > > Is there really a reason to re-invent the wheel?

    > > The right combination of the anchor behaviour with paralax 0,0 works with any fullscreen setting..

    > >

    > > https://dl.dropboxusercontent.com/u/485 ... nchor.capx

    > >

    >

    > LittleStain Thanks for the example, here's a new one with a mockup HUD for this exercise, https://www.dropbox.com/s/g4curnknsl789 ... .capx?dl=0 - if you press S to change the scaling, you'll notice it's not wide enough. I doubt I could use anchors to keep everything correctly sized on that change of scaling for this type of HUD?

    >

    I doubt you could too..

    I don't doubt it could be done, though..

    LittleStain So, would creative usage of anchoring be best for this example I've given, or could things still be resized with some sort of layer scale?

  • As you have already noticed, using layerscale doesn't give you the results you expect..

  • As you have already noticed, using layerscale doesn't give you the results you expect..

    LittleStain mainly I would imagine because I haven't worked out how I could calculate how to dynamically resize a layer with a visual width of 640 to whatever monitor resolution the user is using. If I knew how to get that figure, it might give me the results I expect?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You should be able to get the scale with: windowwidth/originalwindowwidth

    It most likely won't work the way you'd want it to, though..

  • You should be able to get the scale with: windowwidth/originalwindowwidth

    It most likely won't work the way you'd want it to, though..

    LittleStain Well, it's a bit bigger, but it doesn't reach the full length. Does it need some sort of clever calculation that figures out the users aspect ratio and divides the height in or something?

  • > You should be able to get the scale with: windowwidth/originalwindowwidth

    > It most likely won't work the way you'd want it to, though..

    >

    LittleStain Well, it's a bit bigger, but it doesn't reach the full length. Does it need some sort of clever calculation that figures out the users aspect ratio and divides the height in or something?

    I'm sorry, but I don't think I can be of any further help on this topic..

    You'll have to re-invent the wheel yourself, or use the one that is already available..

    I gave you a link to a working example of one way to do the scaling and I guess that's all I can do..

    By the way, you should really adjust the origins of your sprites in the hud example capx..

    Also, adjusting the settings of the anchor behaviour is ofcourse nescessary for it to work..

  • >

    > > You should be able to get the scale with: windowwidth/originalwindowwidth

    > > It most likely won't work the way you'd want it to, though..

    > >

    > LittleStain Well, it's a bit bigger, but it doesn't reach the full length. Does it need some sort of clever calculation that figures out the users aspect ratio and divides the height in or something?

    >

    I'm sorry, but I don't think I can be of any further help on this topic..

    You'll have to re-invent the wheel yourself, or use the one that is already available..

    I gave you a link to a working example of one way to do the scaling and I guess that's all I can do..

    By the way, you should really adjust the origins of your sprites in the hud example capx..

    Also, adjusting the settings of the anchor behaviour is ofcourse nescessary for it to work..

    Thanks for your help so far, LittleStain so it may be possible to do this for all of the HUD elements with anchoring?

  • Did it with anchors, just like css, thanks for all of your help LittleStain !

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