Game Development Community

World, Window, and Map Positioning

by Seth Willits · in Torque Game Builder · 12/09/2005 (7:20 pm) · 3 replies

Is there a chunk of text explaining how the areas for the view port and maps work? Going through the platformer tutorial on TDN, %layer.setPosition("0 0"); puts the layer off in never never land where I can't see it, and any numbers I play with I can't get it on screen. I'm also seeing the dreaded seams.... AHHHH!!!!

#1
12/10/2005 (8:18 am)
First - the dreaded seams... if you are not running T2D 1.1 alpha #1, then live with it... seams are removable, but it's a bit more work. The easiest way to eliminate it in 1.0.2 is to use the special ImageMapDatablock property indent = 0.5; (I think it's indent) Google isn't working on GG right now, so I can't find it. In 1.1, there is a doc that describes datablocks in detail and the properties that control filtering and artifacts. These completely eliminated the problem for me, where I was never able to get a perfect solution in 1.0.2.
#2
12/10/2005 (8:25 am)
Second - a tile map's position represents the center of the tile map. There are two things then, that determine its visibility (assuming you haven't done something obviously wrong, like setEnabled = false; or setVisible = false; or forget to setSize on the tilemap): they are the placement of the t2dSceneWindow and the Camera set up. The t2dSceneWindow is generally set up as full screen in your .gui file: position "0 0" and extent "640 480" with sizing set to "width" and "height." This gives you a full screen control to render into.

The Camera can have many configs. By default (from the spaceshooter example) the camera is set to "0 0 100 75" which makes a 100:75 (or 4:3) aspect ratio with the center at (0, 0)... meaning that the coordinate range is (-50, -32.5)-(50, 32.5). There are many ways to set the camera, though, another possibility is to set the Zoom to 2.0 which would reduce the effective coordinate range by a factor of 2 (-25, -16.25)-(25, 16.25). Still again, you could also set up your camera to have (0, 0) as the origin with a camera set up of "50 32.5 100 75" which would give you a coordinate range of (0, 0)-(100, 75).

Given that I don't have your code in front of me (and I'm not really interested in debugging you code ;-) ), I would recommend starting by checking all of these things.
#3
12/10/2005 (12:17 pm)
To add to this, simply use "%layer.setArea()" to specify the area you want your tile-layer to cover. You can do this with any alpha#1 object. In the case of a tile-layer, it will default with the logical tile (0,0) at the top-left of the "area".

In v1.0.2, the fields was called "inset" and allowed you to specify a texel-inset but it was a nasty hack. In the alpha, you can either used no-filtering (which doesn't show any artifacts) or use filtering but specify "filterPad = true" in your datablock(s).

In alpha#2, filterPad will be on by default if appropriate.

Also in the alpha#2, you'll be able to do the following "%layer.setArea( t2dSceneWindow.getCurrentCameraArea() );" which sets the object, in this case a tile-layer, to be the area that the camera is viewing.

- Melv.