Game Development Community

Documentation: setPosition

by Vern Jensen · in Torque Game Builder · 06/19/2006 (10:47 pm) · 3 replies

In the TGB Reference, in the t2dSceneObject section, setPosition should explain HOW it positions the object according to the x and y coordinates you pass. Does it place the object's upper-left corner at that location? Does it center the object at that location? etc.

-Vern

#1
06/19/2006 (10:50 pm)
Oops. Wrong forum. I'll repost in Suggestions.
#2
06/20/2006 (8:38 am)
I have a question related to this. Is there a way to change how it positions the object? Say, from using to the center to using the upper left corner?
#3
06/20/2006 (10:28 am)
Not that I know of, but I found a way to work around this. My game uses a tile background and I want some objects to be placed exactly ontop of a tile not overlapping 2 or 3. So heres what I did just in pseudocode

x,y = position you want to place object at

// gets "coordinate" number of tile at that location, Not the "position"
tilecoords = tilelayer.picktile(x,y);
tilex = getword (tileposition 0)
tiley = getword (tileposition 1)

//tiles are 16x16.
//and the object i am placing is 16x16.

newx = tilex*16 + (any offset your tilelayer has from the left side of the screen) + 8
newy = tiley*16 + (any offset your tilelayer has from the top of the screen) + 8

// +8 moves the point from the topleft corner of the tile to the center!

obj.setposition(newx,newy)