SceneWindow2D and it's position and subsequent coordinates
by rennie moffat · in Torque Game Builder · 09/25/2009 (12:18 am) · 12 replies
From my understanding, the sceneWindow2D is the essentially the camera view. If this is true. Is the xy coordinates inside the sceneWindow2D always the same? I say this meaning, I am making a game with a moving camera, the camera rules over the player. The player is confined with in this sceneWindow2D. So would SceneWindow2D (x, y) be the same no matter where the sceneWindow was relative to the actual entire level?
About the author
My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.
#2
or if the camera move 10 units to the right, does 0,0 become 10,0?
09/25/2009 (11:41 am)
Specifically what I am asking is, are the camera's view coordinates always the same? is 0,0, relative to the camera always 0,0?or if the camera move 10 units to the right, does 0,0 become 10,0?
#3
Of course, when you move the camera 10 units to the right, (0,0) has moved 10 units to the left on your computer's monitor.
So to the answer the question "are the view coordinates always the same", the same is no. If your camera centered around (0,0) and then moved 10 units to the right, you can't add a new object at (0,0) and have it appear at the center of the screen. It will appear 10 units to the left.
If you need to find the coordinates that the camera is seeing (say to find "stage left"), there are several functions in the scene window to do that.
09/25/2009 (2:17 pm)
(0,0) will always be (0,0) in the scene. No matter where the camera is, if you place objects at (0,0), they'll be at the same spot in the scene.Of course, when you move the camera 10 units to the right, (0,0) has moved 10 units to the left on your computer's monitor.
So to the answer the question "are the view coordinates always the same", the same is no. If your camera centered around (0,0) and then moved 10 units to the right, you can't add a new object at (0,0) and have it appear at the center of the screen. It will appear 10 units to the left.
If you need to find the coordinates that the camera is seeing (say to find "stage left"), there are several functions in the scene window to do that.
#4
09/25/2009 (3:08 pm)
So would it be possible to link the players position to the sceneWindow instead of worldPosition?
#5
09/25/2009 (3:14 pm)
It depends upon your game. If your object needs to interact in ANY way with the world (even if it's not collisions, but something as mundane as objects passing in front of it), then you cannot.
#6
See the reason is, for me, that I want my player's world limits to be determined by the camera view, trick is the camera is constantly moving along the xAxis.
09/25/2009 (4:21 pm)
hmm, could you explain why?See the reason is, for me, that I want my player's world limits to be determined by the camera view, trick is the camera is constantly moving along the xAxis.
#7
Perhaps someone could help me out with this.
I am trying to wrap my head around how I would have my player use the camera view as his world limits. The only trick in mine is that the camera moves at xUnits=20.
getCurrentCameraPosition()
will get the current camera positon. But I am unsure how to plug that in, relate it to the object. The best my head can do right now is
sorry for posting this weak code but it is late. If anyone has some easy pointers for me I would gladly take them
Thanks.
09/25/2009 (10:21 pm)
...Perhaps someone could help me out with this.
I am trying to wrap my head around how I would have my player use the camera view as his world limits. The only trick in mine is that the camera moves at xUnits=20.
getCurrentCameraPosition()
will get the current camera positon. But I am unsure how to plug that in, relate it to the object. The best my head can do right now is
function playerClass::getWorldPosition(%this)
{
$playerClass.getCurrentCameraPosition()
{
if at left limit clamp
if at right limit clamp
}sorry for posting this weak code but it is late. If anyone has some easy pointers for me I would gladly take them
Thanks.
#8
I'm assuming a few things here that I'm not sure of but hope this will get you going anyway.
09/26/2009 (4:01 pm)
Hey, I don't have TGB close by to try this one out, nor am I a great coder.. but assuming getCurrentCameraPosition() returns the center of the sceneWindow in world coords, take that value minus the player's world coords position. Then if that value is bigger than getCurrentCameraSize() / 2 it means the player is out of the camera's view.I'm assuming a few things here that I'm not sure of but hope this will get you going anyway.
#9
Thanks man!
[:]...CK
09/26/2009 (5:33 pm)
hmm, that actually seems pretty logical. My brain is fried right now and its Saturday, the chances of me happily coding this today are not so good. May wait till Monday But thanks, For some reason this problem was a parallax I could not get my head around, but yours seem so easy.Thanks man!
[:]...CK
#10
Thanks.
R
10/06/2009 (1:48 pm)
Hi I have just made a code, a behavior, which seems much simpler compared to having greater success, but It still does not work, can some one go over this and tell me where I am going wrong?Thanks.
R
#11
Hope that helps!
10/06/2009 (1:59 pm)
It looks like the behavior you've posted here will work just fine! It is simpler than greater success, but nothing looks wrong with it.Hope that helps!
#12
;)
10/06/2009 (2:16 pm)
Definite, I guess i have just been underestimating myself. Kinda staying in the womb, guess I needed to get out and explore the world of behaviors and their simplicity.;)
Associate William Lee Sims
Machine Code Games
If you're talking about GUI objects (say, a GuiButtonCtrl), then the coordinates at a fixed location on your monitor stays the same. If your sceneWindow2D's GUI coordinates are at (0,0) and extend to (800,600), then as the camera moves, these coordinates do not change and the upper land-hand coordinates will always be (0,0).