Hello Guest

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - AdamOwen

Pages: [1]
1
Support / 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!

Pages: [1]