Hello Guest

Author Topic: Same size and position in graphics change  (Read 12030 times)

Siddharth3322

  • Newbie
  • *
  • Posts: 29
    • View Profile
Same size and position in graphics change
« on: January 24, 2014, 12:58:40 pm »
I am using tk2d for my 2d game development and quite happy with this tool.
But I have a question regarding multiple platform support although I want to mention that it was a natural behavior but I want to suggestion in that.

For level desing I use 480x320 resolution as 1x and for second resolution I use 1024x768 as 2x. I create a level using my native resolution but my script detect that I have to load second graphics.
At that time second graphics loaded but using old position and size only.

Following image demonstrate my problem correctly. So I want some suggestion to correct this situation.


unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Same size and position in graphics change
« Reply #1 on: January 24, 2014, 02:34:56 pm »
Position and size doesn't change so you don't have to reposition anything. Use the tk2dCamera to rescale the camera when the resolution changes. Eg. Set the override to FitVisible to start.

Siddharth3322

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: Same size and position in graphics change
« Reply #2 on: January 25, 2014, 06:49:26 am »
First thank to you for replying me. It is big thing to me to get reply to me.
Sorry for my stupid question but how to scale camera? Are you talking to change zoom factor?

If yes then as per my assumption I get single dimension to set focus on game area and as a result I get black bars. So basically starting multiple graphics usage to tackle only this issue.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Same size and position in graphics change
« Reply #3 on: January 25, 2014, 09:47:17 am »
No, check the overrides tab - thats what they're there for. Change it to Fit Visible for starters.

Siddharth3322

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: Same size and position in graphics change
« Reply #4 on: January 27, 2014, 09:52:30 am »
I get new graphics loaded but with above image only. Here I attach my camera override so that you guide me properly.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Same size and position in graphics change
« Reply #5 on: January 27, 2014, 12:39:50 pm »
That looks correct.
One potential problem is your 1x and 2x resolutions. As the names suggest they should be 1x and 2x the size, so 0.5x 1024 = 512, not 480. While it will work, it will be more complicated as it will change the size of the sprite.

Assuming you don't change the texture resolution, does it work properly then? What does your game window look like when set to then native resolution? For that matter what is your native resolution in tk2dCamera?

Siddharth3322

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: Same size and position in graphics change
« Reply #6 on: January 27, 2014, 01:22:00 pm »
First of all my three selected resolution are :
  • 960x640
  • 1920x1080
  • 2048x1536

Is it correct? Here I chose most widely used aspect ratios of three platforms for which I am targeting.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Same size and position in graphics change
« Reply #7 on: January 27, 2014, 01:31:57 pm »
What is your native resolution in the tk2dCamera, and when your game window is set to that resolution does it look correct?

Siddharth3322

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: Same size and position in graphics change
« Reply #8 on: January 27, 2014, 01:38:53 pm »
My tk2dCamera native resolution is 960x640 and in that resolution every thing looks perfect.
Following image demonstrate that thing.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Same size and position in graphics change
« Reply #9 on: January 27, 2014, 02:08:54 pm »
It looks like you're on an old version of tk2d, and when you updated Unity that version became out of date. I don't think it'll pick up the correct game window resolution either.

Siddharth3322

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: Same size and position in graphics change
« Reply #10 on: January 27, 2014, 02:22:00 pm »
My current version of 2D Toolkit is 2.2.3. Also I checked with version 2.3.3 but I reply with no change in output.
Is that thing creating problem for me?
« Last Edit: January 27, 2014, 02:47:11 pm by Siddharth3322 »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Same size and position in graphics change
« Reply #11 on: January 27, 2014, 02:52:58 pm »
Please update (the error message you're seeing in the console is an error, not just a warning). After that, switch your game window to 1920x1080 and post what you see. It should fit the screen.

Siddharth3322

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: Same size and position in graphics change
« Reply #12 on: January 27, 2014, 02:59:10 pm »
When I use tk2d version 2.3.3 there is no error message on console.
I run my game and as a result I got following output in preview and graphics of 1920x1080.

Also I want to mention some coding that I used.
I create init scene which has empty game object. In empty game object I write following code also that is not final but for testing purpose it is ok.

Then I switch to my actual game scene.
« Last Edit: January 27, 2014, 03:05:51 pm by Siddharth3322 »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Same size and position in graphics change
« Reply #13 on: January 27, 2014, 03:03:10 pm »
Remove that code. What does it look like without it.
As I mentioned before your 2x texture must be twice the size of the 1x texture. Not bigger, or smaller.

Siddharth3322

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: Same size and position in graphics change
« Reply #14 on: January 27, 2014, 03:05:23 pm »
If only use twice big texture then how to support multiple aspect ratios?