2d art size VS resolution
by Christian M Weber · in Torque 2D Beginner · 11/06/2014 (6:34 pm) · 3 replies
I have a question/problem with loading art into torque2d 3.1.
I'll give an example. I load a texture and render it at say, 1024 768 res. I have a circle, and it's a circle still when being rendered in game.
Now, I switch to 1920 1080 resolution. Now my circle is now stretched to an oval.
Any ideas how to fix this?
My in game camera is...
mainWindow.setCameraSize( 100, 75 );
And I'm loading the Image size at "100 75".
I understand using the above code will make my circle into an oval, so is there something I can do to change that?
Thanks.
I'll give an example. I load a texture and render it at say, 1024 768 res. I have a circle, and it's a circle still when being rendered in game.
Now, I switch to 1920 1080 resolution. Now my circle is now stretched to an oval.
Any ideas how to fix this?
My in game camera is...
mainWindow.setCameraSize( 100, 75 );
And I'm loading the Image size at "100 75".
I understand using the above code will make my circle into an oval, so is there something I can do to change that?
Thanks.
About the author
#2
11/07/2014 (6:07 am)
Don't worry so much about absolute size and focus on aspect ratio - that way you don't have to worry about the camera size. This has come up before and I believe Practicing posted a snippet of script that addresses it cleanly - just have to find it.
Torque Owner Christian M Weber
I only tested this on PC. I can't get Eclipse/Android working. And I don't know how to load my app on my IPad.
I tested 1920 1080 and 1024 768 images.
Code below assumes camera size 100 75. (Some TOYS use camera size 40 30 and won't work with the code below)
Anyone else wanna check this out?
// setGameResolution(mainWindow) function setGameResolution(%SceneWindow, %ResX, %ResY, %ScreenDepth, %FullScreen) { // Did we pass a resolution? if blank, assume defaults. if(%ResX $= "") { if ( $pref::iOS::DeviceType !$= "" ) { %resolution = iOSResolutionFromSetting($pref::iOS::DeviceType, $pref::iOS::ScreenOrientation); } else if ($platform $= "Android") { %resolution = GetAndroidResolution(); } else { if ( $pref::Video::windowedRes !$= "" ) %resolution = $pref::Video::windowedRes; else %resolution = $pref::Video::defaultResolution; } %ResX = getWord(%resolution, 0); %ResY = getWord(%resolution, 1); %ScreenDepth = getWord(%resolution, 2); } if(%FullScreen $= "") { if ($platform $= "windows" || $platform $= "macos") %FullScreen = $pref::Video::fullScreen; else %FullScreen = true; } // Can't go smaller then 640 X 480 if(%ResX < 640) %ResX = 640; if(%ResY < 480) %ResY = 480; if(%ScreenDepth $= "") %ScreenDepth = 32; // 32 bit color is default // setup camera size (4:3 ratio is 100 75, wide screen, 1080p for example, is about 100 57) %camX = 100; // Calculate aspect ratio %AspectRatio = %ResX / %ResY; // height %camY = %camX / %AspectRatio; // adjust camera size for box or wide screen %SceneWindow.setCameraSize( %camX, %camY ); // Debug, make sure it all looks good. //echo (" [Resolution: "@%ResX SPC %ResY@"] - [AspectRatio: "@%AspectRatio@"] - [Camera Size: "@%camX SPC %camY@"]"); // set resolution setScreenMode( %ResX, %ResY, %ScreenDepth, %FullScreen ); }EDIT: Examples, at different resolutions
setGameResolution(mainWindow, 640, 480)
4:3http://s11.postimg.org/4beqsd4rj/480.png
setGameResolution(mainWindow, 1280, 720)
16:9[img]http://s11.postimg.org/we2pzhbvj/720.png[/img]
setGameResolution(mainWindow, 1024, 768)
4:3[img]http://s11.postimg.org/fc9vxdx0f/786.png[/img]