Hello Guest

Author Topic: Does 2D toolkit support multiple resolution support for mobile?  (Read 17719 times)

aaron7090

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Does 2D toolkit support multiple resolution support for mobile?
« Reply #15 on: December 06, 2013, 12:34:36 am »
The preference's platform switcher is showing the correct sprite for 1x, 2x and 4x. SetPlatform is running first under script execution order.

edit: ok it looks fine if I have a scene before with the setPlatform script and then navigates to the second scene with the 2x graphic.. there must be a better way of doing it?
« Last Edit: December 06, 2013, 04:09:45 am by aaron7090 »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Does 2D toolkit support multiple resolution support for mobile?
« Reply #16 on: December 06, 2013, 10:25:47 am »
Is this just an editor thing? Its sometimes a bit hard to ensure everythings unloaded properly in the editor before starting the game, but it should work 100% in game.

aaron7090

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Does 2D toolkit support multiple resolution support for mobile?
« Reply #17 on: December 07, 2013, 09:03:37 pm »
Doesn't seem to be just an editor issue. I put the build onto the phone and the 4x graphic only appears if the scene before it has the setPlatform code run. I'm just going to throw a dummy screen at the start to set the platform.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Does 2D toolkit support multiple resolution support for mobile?
« Reply #18 on: December 07, 2013, 10:23:12 pm »
Start runs after Awake. The sprites get initialised in Awake. You probably should change your init point to Awake and that should fix this.

aaron7090

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Does 2D toolkit support multiple resolution support for mobile?
« Reply #19 on: December 08, 2013, 03:24:00 am »
Ah that was it, thanks!

aaron7090

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Does 2D toolkit support multiple resolution support for mobile?
« Reply #20 on: January 06, 2014, 12:32:51 am »
OK so this works the graphic changes but I think there is an issue?

I have a graphic that is 100x100 which is the 1x graphic.

Then I have the 200x200 which is the 2x graphic.  The graphic switches between the 1x/2x graphics fine but the issue is that the 2x graphic isn't any bigger even when I test in unity with the preferences. It seems to replace the 1x graphic but keep its small size.

I am using the tk2dsprite script for that gameobject.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Does 2D toolkit support multiple resolution support for mobile?
« Reply #21 on: January 06, 2014, 01:14:07 am »
That is expected. The asset sizes are always the same physical size to avoid having to reposition everything when the platform changes. Think of it as changing the amount of detail.

aaron7090

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Does 2D toolkit support multiple resolution support for mobile?
« Reply #22 on: January 06, 2014, 04:59:20 am »
Oh okay.

I'm testing on a 800x480 resolution in unity using a image that is 300x200. That looks fine but on some devices the resolution is 1280x720 and the 300x200 image is too small. This 300x200 graphic is centered on the screen.

What's the best thing to do in this case? Should I just show/hided the appropriate sized graphic?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Does 2D toolkit support multiple resolution support for mobile?
« Reply #23 on: January 06, 2014, 10:44:58 am »
Have you looked at the tk2d camera override feature - this is meant to solve this very problem by rescaling the camera to fit. You design your game for one resolution, then have the override rescale it to fit other resolutions and aspect ratios. That totally decouples the 2 issues of resolution management, and detail management.

11pika11

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Does 2D toolkit support multiple resolution support for mobile?
« Reply #24 on: January 11, 2014, 01:57:54 am »
Hey... just had a little project in corona sdk. they set the @2x and @4x with a "scale factor".
the scale factor is calculated simply by dividing the width of the "current device" by the width of "native resolutions.

Quote
600 / 320 = 1.875   --Kindle Fire & Nook
640 / 320 = 2.0     --iPhone 5
768 / 320 = 2.4    --iPad
800 / 320 = 2.5     --Kindle Fire HD / Nexus7
1200 / 320 = 3.75   --Kindle Fire HD 8.9
1536 / 320 = 4.8   --Retina iPad
(from corona sdk blog)

what they suggest is that if the scale factor is greater than 1.5 you should use @2x and if it is greater than 3 use @4x

so you could do this by using Screen.width in Unity and dividing it by the width of your native resolution (which you set up with tk2d)

hope this helps!

http://docs.unity3d.com/Documentation/ScriptReference/Screen-width.html


tyapichu

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Does 2D toolkit support multiple resolution support for mobile?
« Reply #25 on: January 14, 2014, 12:52:11 pm »
Have you looked at the tk2d camera override feature - this is meant to solve this very problem by rescaling the camera to fit. You design your game for one resolution, then have the override rescale it to fit other resolutions and aspect ratios. That totally decouples the 2 issues of resolution management, and detail management.

can you explain what should i do if difference between planforms is in DPI? i've got a Tab with 1280x800 resolution 10.1 inches and a phone 1280x768 4.5. i set tk2dSystem.CurrentPlatform = "2x" on smaller device accordingly DPI. but camera stays the same. i can't use camera override cause matching by Resolution or Aspect doesn't mutch to me. so i have to change sprite size. may be you've got better solution.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Does 2D toolkit support multiple resolution support for mobile?
« Reply #26 on: January 14, 2014, 01:23:03 pm »
1x and 2x textures are supposed to be 1x and 2x the size. Your difference is pretty minuscule isn't it? 768 vs 800. Why would you want to switch to a 2x texture on that platform?

tyapichu

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Does 2D toolkit support multiple resolution support for mobile?
« Reply #27 on: January 14, 2014, 06:09:40 pm »
the problem is in DPI. for example i have a button. it has size 64x64 pixel and on Tab with 1280x800 10.1 inch screen (DPI about 150) it is suitable for finger touch. but on phone with 1280x768 4.5 screen (DPI about 300) 64x64 button is more than 2 times smaller - it's not suitable for finger. i'm checking DPI on start of game and changing CurrentPlatform to "2x" if DPI is more than 250 so game will use 128x128 art for my button on phone. but sprite size stays 64x64 meters which are not good for phone. my button becomse 2 pixels per meter but camera stays 1 pixel per meter. i have two ways to solve this problem: 1) change camera size to 2 pixel per meter (not usable in runtime, didn't find haw) or 2) change sprite size and position checking current CurrentPlatform. so i used second way - by changing button size it becomed like 128x128 meters and suitable for finger. but i'm not shure this way is good enought. first way whould be better i think. or you have another way to solve my problem i didn't find.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Does 2D toolkit support multiple resolution support for mobile?
« Reply #28 on: January 14, 2014, 06:22:53 pm »
Use a custom override. Set the resolution, then set the scale to whatever you need it to be. If you want full control, remove all overrides leaving one - then change that from your own code. You can scale as you like based on your own logic