2D Toolkit Forum

2D Toolkit => Support => Topic started by: Siddharth3322 on January 24, 2014, 12:58:40 pm

Title: Same size and position in graphics change
Post by: Siddharth3322 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.

Title: Re: Same size and position in graphics change
Post by: unikronsoftware 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.
Title: Re: Same size and position in graphics change
Post by: Siddharth3322 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.
Title: Re: Same size and position in graphics change
Post by: unikronsoftware 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.
Title: Re: Same size and position in graphics change
Post by: Siddharth3322 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.
Title: Re: Same size and position in graphics change
Post by: unikronsoftware 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?
Title: Re: Same size and position in graphics change
Post by: Siddharth3322 on January 27, 2014, 01:22:00 pm
First of all my three selected resolution are :

Is it correct? Here I chose most widely used aspect ratios of three platforms for which I am targeting.
Title: Re: Same size and position in graphics change
Post by: unikronsoftware 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?
Title: Re: Same size and position in graphics change
Post by: Siddharth3322 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.
Title: Re: Same size and position in graphics change
Post by: unikronsoftware 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.
Title: Re: Same size and position in graphics change
Post by: Siddharth3322 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?
Title: Re: Same size and position in graphics change
Post by: unikronsoftware 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.
Title: Re: Same size and position in graphics change
Post by: Siddharth3322 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.
Title: Re: Same size and position in graphics change
Post by: unikronsoftware 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.
Title: Re: Same size and position in graphics change
Post by: Siddharth3322 on January 27, 2014, 03:05:23 pm
If only use twice big texture then how to support multiple aspect ratios?
Title: Re: Same size and position in graphics change
Post by: unikronsoftware on January 27, 2014, 03:09:15 pm
Thats up to you. You can have the image clip in the lower resolution, load a custom background using Resources.Load for different aspect ratios, etc. Depends on what you want with your game.
Title: Re: Same size and position in graphics change
Post by: Siddharth3322 on January 27, 2014, 03:12:34 pm
Thanks for your suggestions. Now I think over that if I stuck then I will disturb you. Sorry for that.
Title: Re: Same size and position in graphics change
Post by: Siddharth3322 on January 29, 2014, 05:48:29 am
When I switch my current platform to iOS then why my texture of size 1024x1024 become 1024x768 in size?
If I switch my target platform to any other then what changes occur?
Title: Re: Same size and position in graphics change
Post by: unikronsoftware on January 29, 2014, 11:58:13 am
It depends on what override you have set up in the camera.
http://2dtoolkit.com/docs/2.4/reference/tk2dcamera.html
Title: Re: Same size and position in graphics change
Post by: Siddharth3322 on January 29, 2014, 12:54:40 pm
Reading last few posts given by you. I think that I have to create textures of size 512x512, 1024x1024 and 2048x2048.
Then which platform texture need to be loaded decided based on device screen resolution and dpi. Am I right in this case?
Title: Re: Same size and position in graphics change
Post by: Siddharth3322 on February 12, 2014, 04:41:55 am
@unikronsoftware, sorry about this repost. But for long time I can't able to solve my problem. If you point some example that it become useful to me and other member also.
Title: Re: Same size and position in graphics change
Post by: unikronsoftware on February 12, 2014, 11:09:20 am
Please register your copy of 2D Toolkit for further support.