Hello Guest

Author Topic: Help with Pixel Perfect Coordinates + Multi Resolution  (Read 4519 times)

jmcguirk

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Help with Pixel Perfect Coordinates + Multi Resolution
« on: April 02, 2013, 07:28:39 pm »
Hey Folks,

Loving 2dToolkit so far - the platforms lean and the tools are really powerful.

Wanted a bit of guidance on how to setup our scenes appropriately to scale.

- We're trying to build a 2D landscape only game targeting all Major iOS (Post Iphone 3) and Android Phones and Tablets.
- We're looking to crop the scene using the jetpack joyride style of scene composition. Essentially hud is anchored to appropriate parts of the screen and the gameboard is cropped, with some gameplay elements anchored or centered.

http://ma.ne.ro/2012/09/05/dealing-with-multiple-resolutions-in-mobile-games/

- Right now our scenes are being constructed (both art and code) in native resolution 1280x768. This allows us to hit Ipad 1, 2, Iphone 4-5 and galaxy phones. For retina, we're doing a 2x scale up of our assets by detecting and dropping the screen resolution on app initialization. Attached is a bit of a guide on what we're doing. Retina is a 2x forced scale up of the orange square. We do this by dropping the resolution (which means 2D Toolkit views it like an Ipad 1/2 effectively).
- We're using a Tk2dCamera with native resolution 1280x768 and a single wildcard override with Autoscale None, Fitmode Center and a few sprite collections (some with Mips enabled)
- Gameplay elements laid out by code are placed using a mixture of absolute pixel coordinates and absolute pixel coordinates offset by screen size.
- HUD is laid out using the Tk2DUIAnchoring system and is appropriately anchoring the hud based on screen size

The issue we're trying to solve now is the 2x scale up on retina isn't high quality enough. The graphics are pretty blurry, and we're not too happy with it. We'd like to support textures in this resolution natively, and it seems like tk2d can support this with the sprite collection and camera overrides - but I can't quite figure out the right combination of settings.

Ideally what I'd be looking for is

- Gameplay scenes continue to be constructed using 1280x768.
- App init tells tk2dSystem which "platform" to use (1x or 2x)
- Higher resolution sprites are swapped with 1:1 scale when they're available, and use a 2x scale when an appropriate sprite isn't available.

However - what I'm seeing is

- Unity coordinates are 1:1 with screen coordinates (i.e. pixel perfect) in the retina display. This is not shocking I think given that we're attempting to use the Jetpack style of scene composition to enable multiple ARs. Do I need to setup a camera override to enable coordinate scaling? If so - how can I scale the appropriate 3:2 part of the scene? In the attached example, I'd want to scale JUST the 3:2 range.
- Tk2DSystem won't take an existing 1x scale asset and scale it when the platform is set to 2x and no 2x asset is available. Though I suspect this might just be an artifact of how I've got my camera configured.
« Last Edit: April 02, 2013, 07:36:34 pm by jmcguirk »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Help with Pixel Perfect Coordinates + Multi Resolution
« Reply #1 on: April 03, 2013, 01:06:47 pm »
If you need different scaling for the UI & the game area, its probably easier to just use two different cameras. You can set up as many cameras as you'd like, just make sure the foreground camera doesn't clear the background image before drawing on it.

The override is set up proeprly, but you should set up an additional one for iPhone 3GS to scale it 2x to fit in the region. You don't have to perform any unit correction for texture swaps - tk2d will ensure the texture swapped sprites are the same physical size containing 2x or 4x denser information. It is probably a good idea to start with 1x sprites and add a 2x override, as otherwise your sprite may end up at a half pixel offset giving you not quite perfect results.

tk2dSystem WILL use the first availabe sprite collection variant when it can't find what its looking for. I think the confusing thing here is that the sprites will always be the same physical size. Since the size doesn't change, it doesn't matter what resolution is being swapped to.

Hope that makes sense?