GetCurrentCameraSize() and getCurrent CameraArea() are off by 1
by Vern Jensen · in Torque Game Builder · 07/06/2007 (2:17 pm) · 4 replies
If I have my camera size set to width = 200, height = 150, when I run my project, if I use echo(), I find that getCurrentCameraSize() and getCurrentCameraArea are both wrong, reporting a width of 199 and height of 149, and the area is off by 1 pixels as well. (If I remember correctly, the bottom and right sides end 1 pixel sooner than they should. For instance, getCameraArea returns a left side of -75, but a right side of 74, instead of 75 as it should be.)
This means that when I try to create a sprite via code instead of in the GUI editor, and size it to match the camera's width or height, it's *wrong*. It won't fill the entire camera height or width if I use the results of those function calls.
This is on a Mac, using 1.5 beta 3. I don't know if the bug exists in prior versions. It might.
Would love to get a reply so I know if this will be fixed in a future version of 1.5.
This means that when I try to create a sprite via code instead of in the GUI editor, and size it to match the camera's width or height, it's *wrong*. It won't fill the entire camera height or width if I use the results of those function calls.
This is on a Mac, using 1.5 beta 3. I don't know if the bug exists in prior versions. It might.
Would love to get a reply so I know if this will be fixed in a future version of 1.5.
#2
07/09/2007 (10:03 am)
Hmm, interesting. It would be great to get feedback from a GG employee, but I can always just add 1 to the returned values myself, if I can assume it will always be off by 1 for the reasons you explained (it makes sense after all), and I can rest assured that the function isn't going to change...
#3
-1 0 1
If -1 is the left side of your window, and 1 is the right side, then the total width here is "2" right? And computing "right - left", or "1 - (-1)" also results in 2, so this would be correct as well. So it should work. I still think there is a bug in Torque.
07/09/2007 (10:13 am)
Actually, I'm not sure your explanation is really the cause of the problem. I don't think it could be. Consider the number line:-1 0 1
If -1 is the left side of your window, and 1 is the right side, then the total width here is "2" right? And computing "right - left", or "1 - (-1)" also results in 2, so this would be correct as well. So it should work. I still think there is a bug in Torque.
#4
Your number line ( -1 , 0 , 1 ) ; The width would be 3 pixels.
Each number represents a true pixel location.
You cannot just use "1-(-1)" beacause in basic math 0 is considered "nothing" and the anwer would be "2". But in the case of measuring pixels on the screen, 0 has to be counted as a location and you have to account for it.
Hard to say if either function could be considered a "bug" or not. Could be that what you expect it to return i just not what it was intended for when it was implemented.
I would say though again, just because of the name of the function "GetCameraSize();",
I think that it should return the full width and not (width-1).
GetCameraArea() has to deal with the 0 pixel location somehow and can't be considered wrong or a "bug" in my opinion.
07/14/2007 (10:09 pm)
Think about it in pixels...Your number line ( -1 , 0 , 1 ) ; The width would be 3 pixels.
Each number represents a true pixel location.
You cannot just use "1-(-1)" beacause in basic math 0 is considered "nothing" and the anwer would be "2". But in the case of measuring pixels on the screen, 0 has to be counted as a location and you have to account for it.
Hard to say if either function could be considered a "bug" or not. Could be that what you expect it to return i just not what it was intended for when it was implemented.
I would say though again, just because of the name of the function "GetCameraSize();",
I think that it should return the full width and not (width-1).
GetCameraArea() has to deal with the 0 pixel location somehow and can't be considered wrong or a "bug" in my opinion.
Torque Owner Dustin Sims
As in your getCameraArea () function. It returns a -75 at the left side. When you count the pixels across the screen, (just as on a basic numberline), you have to pass 0 to get to 74 and that 0 location has to count as 1 pixel. So -75 to 74 counting the 0 location is in fact 150 pixels.
I'm sure your wondering more of whether it will change or not though.
I would say that they would not be able to change the getCameraArea() for reasons stated above but the getCurrentCameraSize() may be a bug and should possibly be fixed.
-dustin