Hello Guest

Author Topic: [SOLVED] tk2dCamera override per resolution?  (Read 4721 times)

Mtihc

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 3
    • View Profile
[SOLVED] tk2dCamera override per resolution?
« on: August 15, 2013, 02:32:34 pm »
I have setup my camera, with Achored Viewport Clipping. The native resolution is 1920x1200. And the smallest resolution on the second camera is 1280x1024.
A bunch of aspect ratios will be supported. And the screen does not have to scale. Yay!

But there's a problem when I select a preview resolution that is smaller than 1280x1024. For example 800x600 or 1024x768.
I guess that's what overrides are for... to scale down in those situations.

So far so good right? Maybe it's silly to have such a high resolution as native resolution?
I realize overrides are created with mobile devices in mind. But I'm not doing anything stupid right?
It works good, until I use a resolution that is too small.

My question is: How do I setup the overrides?
It would be nice if I could do Fit Height, whenever the resolution is smaller than 1280x1024.
Or maybe, I can make very specific overrides for every possible resolution. But that seams overkill.
Although, I suppose the player will eventually be able to change the resolution settings of the game. How would I produce a dropdown list of resolutions? I went a little bit off topic.

All help is welcome. Have I said anything weird? Am I even on the right track?

Thanks in advance
« Last Edit: August 18, 2013, 09:49:03 pm by Mtihc »

Mtihc

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: tk2dCamera override per resolution?
« Reply #1 on: August 18, 2013, 08:21:09 pm »
Bump. Maybe it helps if I tell you it's a 2D sidescroller.

Checkout the attachment. I colored the background, so you can see what's visible in different resolutions.
Thanks to Anchored Viewport Clipping, nothing needs to be scaled for the following resolutions.
1920x1200   16:10 scale 1
1920x1080   16:9 scale 1
1600x1200   4:3 scale 1
1280x1024   5:4 scale 1

But when the resolution is smaller than 1280x1024, things start to mess up. In the screenshot, the resolution is 1024x768. And as you can see, the camera does not render the entire green background. This is expected, because I have setup the viewport clipping that way.

I could really use some directions. How to setup camera for 2D sidescroller, supporting multiple resolutions?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: tk2dCamera override per resolution?
« Reply #2 on: August 18, 2013, 09:23:23 pm »
I couldn't tell you what you'd want to do for your specific use case, but the good news is, you can simply write a script to choose either fit width or fit height depending on the resolution.

Basically, set up tk2dCamera.resolutionOverride[0] as a wildcard override in the inspector. Later on, in your script, grab hold of this and set it up the way you want it to from your script. Being a wildcard override, it will be picked for all resolutions, so you can pretty much do what you want with it.

Mtihc

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: tk2dCamera override per resolution?
« Reply #3 on: August 18, 2013, 09:45:28 pm »
Ah that sounds perfect. I just have to write the algorithm then. I think I have it partially in my head already.

Cool. I have no more questions for now. Thanks.