Hello Guest

Author Topic: portrait pixel perfect issue  (Read 4648 times)

blueskined

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 11
    • View Profile
portrait pixel perfect issue
« on: February 09, 2013, 06:40:28 pm »
Hi there:

Just purchased 2DTK, trying to play around, and a question came up:
when I generate a sprite collection, I set the height of the target to 640- which means a landscape view with height 640, and the generated atlas is working without any issue, but when I need a portrait layout, the generated sprite turns out to be not correct!

I also try to generate with landscape, but as soon as I change the game view to portrait, the sprite got really blurry!
can someone point out where I did wrong? or is there any setting for this?

thank your for any suggestion.

BS!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: portrait pixel perfect issue
« Reply #1 on: February 09, 2013, 06:44:24 pm »
You can get pixel perfection in landscape view by changing the ortho size on your camera. Or, if you use tk2dCamera (http://unikronsoftware.com/2dtoolkit/doc/tutorial/tk2dcamera.html), then you can configure the camera to be pixel perfect in any resolution - just remember to tick the "Use tk2dCamera" option on your sprites in addition to having the correct camera set up if you wanna try this.

blueskined

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: portrait pixel perfect issue
« Reply #2 on: February 09, 2013, 06:52:57 pm »
Hi thanks for your quick response!
I dont want to mess with the 2k camera for now, caz I been look through all the demos, no one used 2k camera, I preffer start from more basic things.
I am just trying to setup by default camera with orth view.

can you give me some hints?
I am setting the orth to 10, and the the collection's orth setting is also 10, height is 960( supposed to be portrait ), and it's not correct.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: portrait pixel perfect issue
« Reply #3 on: February 10, 2013, 01:09:15 pm »
Lets say your "native" resolution the sprites are built at, is for an ortho size of 2 and a resolution of 960x640 (landscape).
When you now switch to portrait with the same parameters, the sprite will appear larger than it was before.

To ensure its the same size in portrait and landscape, what you need to do is change the ortho size on the camera to compensate for the changed resolution.

newOrthoSize = oldOrthoSize * newResolutionHeight / oldResolutionHeight;

In this case, the new ortho size should be:
= 2 * 960.0f / 640.0f;
= 3

The size will then be correct, displayed at this resolution. You can use the same logic for different resolutions / aspect ratios.

blueskined

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: portrait pixel perfect issue
« Reply #4 on: February 10, 2013, 01:27:34 pm »
got it ~ thanks! :)