Author Topic: Handling Multiple Resolutions AND Aspect Ratios  (Read 5746 times)

samurai413x

  • Guest
Handling Multiple Resolutions AND Aspect Ratios
« on: May 03, 2012, 06:12:09 PM »
Hi everyone!

I am trying to make my game compatible for 4 resolutions: iPhone Tall(320x480), iPhone 4G Tall (640X960), iPad Tall (768x1024), and eventually iPad Retina Tall (1536 x 2048).

From the research I've done, it looks like I need to have 2 sets (based on aspect ratio) of 2 texture atlases (based on high/low definition):

Set 1: iPhone (2:3)
iPhone SD (set Pixel Size to 2)
iPhone HD (set Pixel Size to 1)

Set 2: iPad (3:4)
iPad SD (set Pixel size to 2)
iPad HD (set Pixel size to 1)

It seems easy enough to detect the resolution and swap the atlas.  But given the fact that when I import a sprite, it shows up with an X and Y scale factor that represents its width and height at that resolution, it seems like I will also have to implement something to rescale every sprite (and possibly other widgets) according to the curent resolution.

Am I correct about this?  It feels like I am missing a piece of the puzzle, but I don't know what it is.

Thanks for your help!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Handling Multiple Resolutions AND Aspect Ratios
« Reply #1 on: May 03, 2012, 06:56:54 PM »
You need to disable the "automatic" checkbox on UIRoot.

samurai413x

  • Guest
Re: Handling Multiple Resolutions AND Aspect Ratios
« Reply #2 on: May 03, 2012, 07:20:45 PM »
Yeah I have that disabled.

I just figured out one thing that was throwing me off (seems like a bug?).  If I switch from iPad resolution to either of the iPhone resolutions, and then press play, the UIImageButton I am testing with shows up out of place, strangely re-scaled, and using different images for its inactive and hover states.  BUT, once I click on the button or highlight it in the Inspector, it suddenly snaps into place, properly scaled.  (I am not worrying about the different image issue yet).

Is this because clicking the button or highlighting it in inspector calls MakePixelPerfect, which fixes things?  Should there be a MakePixelPerfect call somewhere else, like in the Start method of UIImageButton?

Thanks for the prompt response!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Handling Multiple Resolutions AND Aspect Ratios
« Reply #3 on: May 03, 2012, 07:48:19 PM »
Might be 2.0.4b. Try 2.0.4c, it should fix any such issues.