2D Toolkit Forum

2D Toolkit => Support => Topic started by: Matt-Cranktrain on September 16, 2013, 11:26:27 am

Title: Getting the True Lower Left of the Screen
Post by: Matt-Cranktrain on September 16, 2013, 11:26:27 am
Hi,

I'm using two tk2dCamera's, one for the game and one for the game's UI, and that was working nicely until I decided to test it out at different resolutions.

The following image illustrates my problem, I'm trying to align a tk2DSprite at coordinates 0,0:

(https://dl.dropboxusercontent.com/u/5612419/Otter/CameraOffset.png)

At the native resolution of 1600x900, it's fine, aligned at the true lower left of the screen. When I change the resolution to a smaller 1024x576, however, it stays at the same point relative to the background tiles, and yet there's plenty more that gets displayed below. I don't mind if more of the game gets shown in the background, but I do need those UI elements aligned to the edges of the screen correctly.

Have I misunderstood some aspect of tk2dCamera or tk2dCameraAnchor? How can I reliably get the 0x0 co-ordinate of the lower left hand corner of the screen, regardless of the resolution?
Title: Re: Getting the True Lower Left of the Screen
Post by: unikronsoftware on September 16, 2013, 12:01:06 pm
tk2dCamera.ScreenExtents.xMin/yMin should give you the bottom left of the screen. You don't need that though - if you create a camera anchor, anchored to the bottom left, and attach your sprite to it with a localposition of 0,0,0, then it will appear at the bottom left always.
Title: Re: Getting the True Lower Left of the Screen
Post by: Matt-Cranktrain on September 16, 2013, 01:07:02 pm
Thank you, all sorted now.