hello together!
i am working on a android game and i want to be sure it looks nice on the iPhone.
mostly i have tested my game on a 800x600 screen.
for all my GUIs i use GUIStyles with the same font with different fontsizes in the True Type Font Importer.
when i now change the platform to iOS and view the game for iPhone Wide 480x320 the font is much to big.
for the iPhone 4G Wide 960x640 the font is fine.
can someone tell me an idea to solve this problem?
my GUI scripts are looking something like this:
var mystyle : GUIStyle;
var mystyle2 : GUIStyle;
var fontColor : Color;
var outColor : Color;
var guiposition : Rect;
function OnGUI () {
////THE BALL
guiposition = Rect ((Screen.width/2)-400, 50, 800, 100);
mystyle2.normal.textColor = outColor;
guiposition.x-=3;
GUI.Label (guiposition, "THE BALL", mystyle2);
guiposition.x +=6;
GUI.Label (guiposition, "THE BALL", mystyle2);
guiposition.x-=3;
guiposition.y-=3;
GUI.Label (guiposition, "THE BALL", mystyle2);
guiposition.y +=6;
GUI.Label (guiposition, "THE BALL", mystyle2);
guiposition.y-=3;
mystyle2.normal.textColor = fontColor;
GUI.Label (guiposition, "THE BALL", mystyle2);
}
use different fonts so they are fine pixel wise. You will actually need 2 different fonts, one for Retina / HD resolution and one for 480x320 and then choose the right one through code logic (assigning it in start to a class wide guistyle which you then use)
But if the game is on android you will already have this in place likely, cause there are devices with 800x480 and devices with 480x320 like resolutions and they will suffer the same problem.
thank you very much for your answer.
this sound like a very good solution that i can also use for the android devices.
because i am a beginner its a little bit hard to imagine how to code this.
you mean something like this?:
////
var UsedFont
var SmallFontStyle : GUIStyle
var BigFontStyle : GUIStyle
if device == iPhone 3G
UsedFont = SmallFontStyle
if device == iPhone 4G
UsedFont = BigFontStyle
or better
if screen resolution bigger than xxx
UsedFont = BigFontStyle
and then
GUI.Label (guiposition, “THE BALL”, UsedFont);
Actually I would only use 1 handle for the GUIStyle and then
var skin : GUISkin;
var font : GUIStyle;
function Start()
{
if (Screen.width >= 800 || Screen.height >= 800)
{
font = skin.GetStyle("bigfont");
}
else
{
font = skin.GetStyle("smallfont");
}
}
the >= 800 test is here just as an example to handle all 4 orientations, if you know that you are portrait only or landscape only you can reduce it to one side of it.
thank you very very much for your answer.
i never used GUISkins before. i read about it in the manual but i not understand it to 100%.
this is like a container for different GUIStyles?
so when i now use 3 different font sizes, i have to make 6 custom styles in this skin? a small and a big one for every of this 3 font sizes.
my game is played in landscape. so which resolution is a good one to switch? i mean what is a good standard for android and the iPhone?
should i use the small font for all under 480x320 and the big for all that is bigger than this?
thank you in advance!