Hello Guest

Author Topic: Camera, Platform, Resolution....got it, but dont understand it fully...  (Read 15751 times)

Intrawebs

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Camera, Platform, Resolution....got it, but dont understand it fully...
« Reply #15 on: January 23, 2013, 11:16:07 pm »
Your suggestion still doesnt help when scaling. 

Im confused as hell now and have spent a lot of time on this.  I want to get this right before I go any further on my project.  I think it would be great if you had a demo scene that handles the following.

My goal is to have containers centered top, centered bottom and centered middle.  The game is played in portrait.  My sprite collections will have 2x and 4x sources....or 1,2 and 4x if it makes sense.  I want everything to auto scale per resolution and want to design at 640x960.  I have a background tiled sprite that is massive, so letter boxing on the sides is not an issue as this tiled sprite is shown.  My 4x sources are all 2 times the size as the 2x source...per your doc this will have the best results.

How should i setup the camera when doing this, I do not want to put in explicit width and height overrides for every possible size as this will be on Android.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Camera, Platform, Resolution....got it, but dont understand it fully...
« Reply #16 on: January 24, 2013, 12:17:36 am »
To set up the camera for this scene, set up the tk2dCamera as follows:
1. Native resolution = 640, 960
2. Overrides, delete everything, and click "Add override" to add a wildcard override. Leave this as it is. Don't add any more overrides.
Your game will now scale to fit the screen, the tiled background will reveal more as the aspect changes.

If you want your game to be "pixel perfect", and only ever scale by whole numbers, then switch AutoScale to "Pixel Perfect Fit".

Note, I haven't mentioned anything about 1x, 2x or 4x collections - it really doesn't matter. They are totally independent to the camera. All sprites from platform specific sprite collections should be the same physical size, so for almost everything, you can ignore that feature even exists.


Your question before wasn't related to this at all, or have I misunderstood it? Didn't you want to move something completely offscreen?

Intrawebs

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Camera, Platform, Resolution....got it, but dont understand it fully...
« Reply #17 on: January 24, 2013, 12:40:33 am »
As I was typing the below you posted, so I will reply to your post.  Correct, my issue was needing to move some stuff around, but the root problem was actually my latest question which was related to my original post of not grasping all this.  Once I get this root issue fixed then moving stuff around should work fine per what you already suggested on that.  Per your recent post, that seems to work great.  But, I dont see the option for "Pixel Perfect Fit" in the camera override, I just downloaded the current version from the asset store as well to double check it wasn't a version issue.  I do see a "stretch to fit".

Below is what I was going to do before you posted your response.  Looks like I dont need to set scale and do what you suggested and then separately pick which asset 2x vs. 4x to load on my own, not a problem.  Thanks for all your help on this!




******************************
I think I now know how to approach this.  I will at game load time, the same time I set 4x vs. 2x also create and have only 1 resolution override.

This override will be...
width = screen.width
height = screen.height
auto scale = none
scale = screen.height / NativeRes.height (see psuedo code below)
fit mode = center

While testing the above logic by manually setting these on the camera this works, everything gets positioned properly.  What I'll be doing is essentially creating 1 wildcard at runtime that is actually meant for the active resolution.  Of course I need to also make sure that when Im setting the scale to also set a matching 4x vs. 2x, which would have impact on the scale.


Some pseudo/hack code here on handling the decision making for 4x vs. 2x and its impact on scale to make sure the best possible scale and source is rendered.

scale = 1
tk2dSystem.CurrentPlatform = "2x"

tempScale = screen.height / 2k2dCamera.NativeRes.height
if tempScale >= 1.5
  tk2dSystem.CurrentPlatform = "4x"
  tempScale = screen.height / (2k2dCamera.NativeRes.height  * 2)
  scale = tempScale ///// here we are scaling down the 4x vs. scaling up the 2x.....need to play with the results to see what looks optimal and when (scale up/down 4x/2x)
else if templScale > 1 AND tempscale < 1.5
  scale = tempScale  /////scale up the 2x...but no more than 1.5 times its original
else if tempScale < 1
  scale = tempScale ////scale down the 2x

//I could then also check if the scale <  .5 and show a 1x vs. the native what I used to design of 2x...I doubt I will ever have a height of < 480

 

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Camera, Platform, Resolution....got it, but dont understand it fully...
« Reply #18 on: January 24, 2013, 12:53:12 am »
Pixel perfect fit is from 1.90 - apologies, I've got that mixed up. It is probably safe to upgrade if you want. Barring any major issues, this current version will go out as is.

Intrawebs

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Camera, Platform, Resolution....got it, but dont understand it fully...
« Reply #19 on: January 24, 2013, 01:58:27 am »
Thanks, this all works great now.  Pixel Perfect Fit works as well.  :)  You may want to sticky the part about getting multiresolution support with the override you suggested.

Intrawebs

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Camera, Platform, Resolution....got it, but dont understand it fully...
« Reply #20 on: January 24, 2013, 07:23:48 pm »
One more question on this, should I still be doing anchor middle center on my sprites in my sprite collection (2x, 4x) with the new override setup you suggested?   Or do you think I should anchor my sprites differently?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Camera, Platform, Resolution....got it, but dont understand it fully...
« Reply #21 on: January 24, 2013, 07:43:05 pm »
No real rule there, whatever works for you will be fine.