Multiple resolutions - solid example

  • This should be sticky, I wish I'd seen it before..

    Why are you setting this: "(LayoutHeight * scaleRatio - WindowHeight) / 2 / scaleRatio" technically the result would always be 0? Or am I missing something?

    I tried to put it in my game prototype and used rex's debugpanel and I also get the values as 0

    All my objects seem resized to same and centered on the screen.

    Not sure what I'm missing. <img src="smileys/smiley18.gif" border="0" align="middle" />

  • > This should be sticky, I wish I'd seen it before..

    > Why are you setting this: "(LayoutHeight * scaleRatio - WindowHeight) / 2 / scaleRatio" technically the result would always be 0? Or am I missing something?

    >

    > I tried to put it in my game prototype and used rex's debugpanel and I also get the values as 0

    > All my objects seem resized to same and centered on the screen.

    >

    > Not sure what I'm missing. <img src="smileys/smiley18.gif" border="0" align="middle" />

    Guess this is what happens if you blindly follow an example.

    I am trying to get my player and objects to scale.

    So wondering if the right way is to set player position to (currentXposition*scaleRatio, currentYposition*scaleRatio) and setting size to (currentXsize*scaleRatio, currentYsize*scaleRatio)

    Anyone?

  • Hi gammabeam,

    The link is showing an "Error (404)"

  • someone has to share the file again. The link is broken

  • oops, sorry guys. I went through my dropbox folder and now it's gone.

    I'll try to find it and post it again!

  • ugh, it's gone... can someone send me the file so I can put it back online? <img src="smileys/smiley19.gif" border="0" align="middle" />

  • Here you go gammabeam <img src="smileys/smiley1.gif" border="0" align="middle">

    Multiple resolutions - solid example.capx

    I knew I had it some place in my disorganized 365GB's of files. lol

  • I reopen this topic asking or others for help.

    Taking your example how can I programmaticaly put an element on the bottom of the screen consistently across different ratios?

    Take this example:

    I want an element to be exactly his height from the bottom of screen (origin center), x is irrelevant:

    At the beginning I was doing this:

    (WindowHeight / scaleRatio) - (sprite.Height/2)

    Which worked on the normal ratio but started doing strange things with different ratios, it became apparent that that H would change with the ratio, so I did a proportion:

    (WindowHeight / scaleRatio) - ( ((sprite.Height* (WindowHeight / scaleRatio))/LayoutHeight) / 2 )

    But doesn't work, why?

    Here is a modified capx showcasing my problem: capx, how can I make the "start" button stick in the same position (bottom of screen - self.Height) across different resolutions?

    Thanks for any help

  • Anyone?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm not sure about the math, bust at a glance, use viewportbottom instead. Windowheight grabs the height of the whole window, rather than just the windows's content.

  • Arima

    Ashley

    I may have stumbled onto a bug?

    After banging my head onto a wall I discovered that for some strange reason viewportbottom/top change value during execution, it looks like it needs to stabilize..

    If you execute it "on start" it returns a value, if you execute it "every tick" it gives a different value (the first is the same as onload) all the subsequent are the correct ones.

    Why?

  • Ahh, that might explain the weird behavior I've been having with my ui. At a guess, it might have something to do with the canvas being resized to full screen at start and so returning a value from before the resize? Not sure exactly...

    I've been getting around it by running the ui placement code for a few ticks before deactivating the group.

  • I ended up creating two global variables that gets populated with viewportBottom/top after an event on the main menu, because I needed it at the very beginning of the "game" layout.

  • Oh duh, yeah, that's a better idea. :)

  • Help me, do not know what resolution is best for my all generation iphones and ipads. Should i draw a different size images and to load them depending on what phone&ipad do i use?, and how to do it? or draw is always high resolution and scale it up?

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