Setting the SceneWindow2D to relative size
by Steve D · in Torque Game Builder · 09/14/2010 (4:52 pm) · 5 replies
Hello everyone, was wondering if anyone can share any experience with this. For my game I have the SceneWindow 2D set to relative size so it scales to any resolution. When my artist was playing through the game he said he noticed some of the ingame art looked a bit wonky at times and not proportionate. Does anyone know if setting the scenewindow to relative might mess up graphics? Would it be better to set the scenewindow to the default "right" and "bottom" and just code a system to manually change it's size based on current resolution?
Hopefully someone has some wisdom to share :)
Hopefully someone has some wisdom to share :)
#2
09/14/2010 (11:43 pm)
Thanks for the reply Will, I looked over your function and I can safely assume that the remarks I'm hearing *are* a result of the scene window being to set to relative and the correct way is a manual change?
#3
Let me know if you run into problems or have questions with it. Later!
09/15/2010 (7:06 am)
That code actually assumes that you've set "right" and "bottom" and manually resize it yourself. That code also keeps the aspect ratio, so that if you design your game, say, at 1024x768, you'll keep that ratio no matter what.Let me know if you run into problems or have questions with it. Later!
#4
This small bit of script below is what I came up with, I'm still experimenting with it but it seems to work. The canvas is set to relative for both sizes and this will take care of this rest. The number 4 which is used in the %width variable is what I came up with for my game to look good at widescreen, you might have to change the number depending on what your game looks like, not sure.
function setAcceptableScreenRatio()
{
%res = getRes();
%x = getWord(%res, 0);
%y = getWord(%res, 1);
if(%y == 600)
%height = 150;
if(%y == 768)
%height = 175;
%currentarea = screen2d.getCurrentCameraPosition();
%field1 = getWord(%currentarea, 0);
%field2 = getWord(%currentarea, 1);
%width = %x / 4;
Screen2D.dismount();
screen2d.setCurrentCameraPosition(%field1,%field2,%width,%height);
screen2d.mount(player);
}
09/24/2010 (5:09 pm)
Hello everyone, I thought I would share this since it might be of use to some people. It kept bothering me to have to change the canvas when the resolution changed (especially for wide screen) and then you would get the black bars on the sides, I did some digging on the forums and discovered that it seems the correct way is changing the camera area when switching to a wide screen resolution, not the canvas. This small bit of script below is what I came up with, I'm still experimenting with it but it seems to work. The canvas is set to relative for both sizes and this will take care of this rest. The number 4 which is used in the %width variable is what I came up with for my game to look good at widescreen, you might have to change the number depending on what your game looks like, not sure.
function setAcceptableScreenRatio()
{
%res = getRes();
%x = getWord(%res, 0);
%y = getWord(%res, 1);
if(%y == 600)
%height = 150;
if(%y == 768)
%height = 175;
%currentarea = screen2d.getCurrentCameraPosition();
%field1 = getWord(%currentarea, 0);
%field2 = getWord(%currentarea, 1);
%width = %x / 4;
Screen2D.dismount();
screen2d.setCurrentCameraPosition(%field1,%field2,%width,%height);
screen2d.mount(player);
}
#5
BTW, I think you might have some errors in your script. Unless you've limited screen resolutions, there will be other heights besides 600 and 768.
Later!
09/24/2010 (11:39 pm)
I would say this is a design issue. For example, I want each user to have the same view of the game, and so the black bars are a necessity. If I switched the camera for a wide or tall screen, those users would have a different experience. On other games, say something like SimCity, changing the camera is ideal. The player wants to use his or her full monitor.BTW, I think you might have some errors in your script. Unless you've limited screen resolutions, there will be other heights besides 600 and 768.
Later!
Associate William Lee Sims
Machine Code Games