Hello Guest

Author Topic: tk2dCamera seems to be offset by a small amount  (Read 4252 times)

AdamOwen

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 8
    • View Profile
tk2dCamera seems to be offset by a small amount
« on: September 10, 2014, 04:29:35 pm »
Hi,

I've come back to 2D Toolkit after a few months and while trying to remember how to set up camera scaling I've come across a problem.

It seems that the tk2dCamera transform is offset by 0.01 in x and y and is causing a tiny gap on the right and bottom of the game.

To reproduce the problem:

1) Create a tk2dCamera and set the native and preview resolution the same (I'm using 960x640 but it doesn't seem to matter).
2) Create a quad the exact size of the camera, so for 960x640 make it x: 9.6, y:6.4
3) You can see the small gap on the right and bottom of the camera preview, changing the camera background to bright red shows up better.
4) Change the tk2dCamera position to x: -0.01, y: 0.01 and the gap disappears and the scene is centered.

If you view this same scene in an orthographic Unity camera with a size of 3.2 there is no gap.

I've tested this a bit and if you use the same settings and slowly start reducing the width of the quad by 0.01 you can see in the Unity camera it stays centered, where in the tk2dCamera the right side shrinks before the left.

I've used a quad as it's easy to test with but I first noticed the problem while trying to use a sprite in a sprite collection (100 pixels per meter on the collection and camera), it also happens with Unity sprites.

I've tested this with the same results in 2.4.0 and 2.5beta2, both in Unity 4.5.3. If it's a stupid setup error on my part please let me know, otherwise I'd love to figure this out as searching didn't turn up any results.

Thanks in advance for any help!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: tk2dCamera seems to be offset by a small amount
« Reply #1 on: September 13, 2014, 12:26:46 pm »
Is this on Windows when running DX11, does it change in DX9 mode? I am aware of an issue which will be fixed in the next 2.5 release. Please confirm if this is the case.

AdamOwen

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: tk2dCamera seems to be offset by a small amount
« Reply #2 on: September 14, 2014, 11:58:31 am »
Yes just tested this, I'm on Windows and can confirm this only happens on in DX11 mode, switching to DX9 fixes it. I only need DX9 so not a problem for my project, good luck with the fix!

Thanks.