Hello Guest

Author Topic: Camera, Platform, Resolution....got it, but dont understand it fully...  (Read 15763 times)

Intrawebs

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 16
    • View Profile
I'm using your TK 2d Camera, I also have two sprite collections that both have a 2x as their current platform and a 4x as an additional platform.  The atlas's all get created just fine.  For the camera I have it setup pretty much like you did and I work at the 640 width x 960 height with my 2x sprites all designed/anchored/positioned just great at that resolution in the editor.  My 4x sprites are all double the size of the 2x sprites and are designed to be full retina on ipad4 (2048 height x 1156).

I then fire up my iPad 2 (1024 height x 768 width).  In the scene before my gameplay I do the following
tk2dSystem.CurrentPlatform = "4x"

The gameplay screen has everything automagically positioned, scaled etc on ipad2.  It looks as if my 4x atlas is used and scaled down 50% (what I want).

What I dont under stand is the camera overrides. Are they needed and when would I use them?  Am I doing anything wrong?

Also, do you have any links in these forums about how people tackled android ratios/resolutions while also using the TK2dCamera?  I purchased multiplatform toolkit asset but so far I haven't needed it.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Camera, Platform, Resolution....got it, but dont understand it fully...
« Reply #1 on: January 10, 2013, 01:09:09 am »
Camera overrides let you rescale the screen for different resolutions and aspect ratios. If you set up a wildcard override, and with the default values, it will scale whatever output you have to fit the screen. Eg. 1024x768 -> 960x640. There are options on how you want to scale, so you can tell it to try to fit width, height and so on.

You aren't doing anything wrong. Have you tried your app on iPhone or other android devices? You'll probably find it already does a lot of what you need - when it doesn't, you'll just need to tweak the overrides to suit.

Intrawebs

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Camera, Platform, Resolution....got it, but dont understand it fully...
« Reply #2 on: January 10, 2013, 03:57:06 am »
Thanks for helping with my sanity check!  Haven't tried the phone yet, need to grab some old ipods around the house and try them (4th and 2nd gens), looks great when forcing the editor to those lower resolutions.

What has been your experience or others when needing to futz with overrides? As in when do you commonly need to if at all?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Camera, Platform, Resolution....got it, but dont understand it fully...
« Reply #3 on: January 12, 2013, 01:33:52 pm »
I just turn on the default override. That pretty much covers most needs.

zeStudio

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Camera, Platform, Resolution....got it, but dont understand it fully...
« Reply #4 on: January 15, 2013, 10:09:07 am »
I'm developing for a resolution of 1920x1080, I'm a bit confused at how to set up the tk2d camera.

In the Camera options I've set the size beneath orthographic to 1920, is this right?

Other settings include native res: 1920x1080, overide of 1920x1080 stretch to fit,
Camera resolution: force editor resolution, 1920x1080.

Also should I scale the artwork for levels at the 1920x2080 resolution or go lower? The sprite collection seems to have trouble creating the larger textures. Do I need to pre-slice them in photoshop once I get them from the artist?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Camera, Platform, Resolution....got it, but dont understand it fully...
« Reply #5 on: January 15, 2013, 11:20:36 am »
In camera options - orthographic size doesn't matter.

The tk2dCamera setup you have is correct.
Make sure you have Use tk2dCamera ticked on your sprite collections and you should get pixel perfect at 1920x1080.


For easiest workflow, you should develop the game at the lowest resolution you intend to support, and then use platform specific collections for higher resolutions.

What do you intend on slicing? Have you tried the dicing feature?

zeStudio

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Camera, Platform, Resolution....got it, but dont understand it fully...
« Reply #6 on: January 15, 2013, 12:51:19 pm »
Cool thanks.

I guess the lowest would possibly be 720p but I'm thinking a lot of artwork would have to be rescaled / remade for other devices so I was going to start with a higher quality experience for 1080p.

Yeah I tried the auto-slicing in the collection editor and it works ok (besides a few small parts it seems to crop by themselves). I guess in my mind I imagined being able to scale a 1920x1080 sized painted graphic and import it as a high resolution background. It just seems I can't import graphics at these high resolutions with the sprite manager?

I'll take another look tomorrow. Thank you for answering my questions. :)

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Camera, Platform, Resolution....got it, but dont understand it fully...
« Reply #7 on: January 15, 2013, 01:13:56 pm »
If your source images are really large, you'll probably run into atlas limits (4096x4096) very quickly. If these are solely for backgrounds, you could just import them as normal 2D UI textures, and use tk2dSprite.CreateFromTexture. As long as you use the same parameters for these as you do your other sprites, they will appear at the correct size.

As with most options, its probably worth spending a short while experimenting to see what works best for you.

zeStudio

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Camera, Platform, Resolution....got it, but dont understand it fully...
« Reply #8 on: January 15, 2013, 01:47:49 pm »
Thanks unikron, I'll try that tomorrow. :)

But yeah, I'm thinking for performance issues it's probably better to splice the graphics up before importing them. I'll have to experiment further. Thank you so much for your prompt responses!

Intrawebs

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Camera, Platform, Resolution....got it, but dont understand it fully...
« Reply #9 on: January 23, 2013, 08:21:04 am »
I develop at 640x960 (so I can see what Im doing) per my original post I still use the same assets.  The problem I have is when I switch to 320x480.  I have an override on the camera set to scale of .5 just like in your demo #11.  I do this so that my 2x atlas can be used for both 640 and 320 widths (if there is a better approach to this let me know).  The problem is, the anchors dont adjust their position automatically because of the scaling override I think, they do adjust when there is no override scaling. 

The graphics do scale and look just fine and in the place they are suppose to be, but Im using some anchors as reference points to do some tweening of objects.  What do you advise for the most seamless workflow.  I know you say develop at the lowest resolution I intend to support but I think I would still have this problem in situations where I need to scale up. 

A simple alternative is to do screenWidth/2 and screenHeight/2 to get middle center vs. using anchors as reference positions. 

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Camera, Platform, Resolution....got it, but dont understand it fully...
« Reply #10 on: January 23, 2013, 09:10:11 am »
Is it the camera anchors which aren't updating properly? I'm not 100% clear on what you mean. If you can post screenshots that would be most excellent. Or email them to support@unikronsoftware.com if you prefer.

Intrawebs

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Camera, Platform, Resolution....got it, but dont understand it fully...
« Reply #11 on: January 23, 2013, 05:09:05 pm »
Its the camera anchor transform position.  I set one up as middle center while at 640x960.  When I run the game and change the resolution to 320x480 the anchor (and all others) stay in the same place.  The anchors move to their respective positions at different resolutions when there is no override for that resolution.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Camera, Platform, Resolution....got it, but dont understand it fully...
« Reply #12 on: January 23, 2013, 06:01:43 pm »
Yes that is expected. When you add an override, it rescale the camera, so the actual resolution in your game remains the same. Your game still thinks its drawing into the native resolution, however you have set that up.

Intrawebs

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Camera, Platform, Resolution....got it, but dont understand it fully...
« Reply #13 on: January 23, 2013, 07:24:04 pm »
How do you advise I solve this problem then.  I need to get the center of the screen with scaling so that I can position objects in their same position but exactly 1 screen to the left or right of the visible screen.

I tried...

Code: [Select]
var centerScreen = tk2dCamera.inst.ScaledResolution / 2;
Center = new Vector3(centerScreen.x, centerScreen.y, 0);

//this is one virtual screen space to the left...not visible
var xPos = Center.x - (centerScreen.x * 2);
screenLeftPos = new Vector3(xPos, Center.y, Center.z);

//this is one virtual screen space to the right...not visible
xPos = Center.x + (centerScreen.x * 2);
screenRightPos = new Vector3(xPos, Center.y, Center.z);

But, the ScaledResolution =400x400 for some reason when an override is set to scale at .5 (with a resolution of 320x480) from the native resolution on the camera of 640 width and 960 height, so I dont understand how it got 400x400.
http://imgur.com/ImjFhlf
« Last Edit: January 23, 2013, 07:30:01 pm by Intrawebs »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Camera, Platform, Resolution....got it, but dont understand it fully...
« Reply #14 on: January 23, 2013, 07:41:57 pm »
tk2dCameraAnchor uses tk2dCamera.ScreenExtents. Check how it positions the anchor in there. You can use the same code to position something at any of the corners, also one "full" screen away too - rect.xMax - rect.xMin = the width of the visible extents.