Sort by screen position?
by Andy Hawkins · in Torque Game Builder · 12/07/2008 (1:35 am) · 4 replies
How do I sort my npcs and monsters and trees and players so as they move up the screen they are drawn behind ones further down the screen?
#2
While you are in the level editor, deselect all objects. You should be editing the scenegraph itself. From here you should be able to see the "Layer Management" rollout in the "Edit" tab. In the dropdown menu for the layer that you wish to sort, select "Y axis". The scene object property "Sort Point" is what determines the sorting of the object. You'll probably need to play around with it until you find a point that works well for your sprites.
12/07/2008 (1:48 am)
You can use layer sorting!While you are in the level editor, deselect all objects. You should be editing the scenegraph itself. From here you should be able to see the "Layer Management" rollout in the "Edit" tab. In the dropdown menu for the layer that you wish to sort, select "Y axis". The scene object property "Sort Point" is what determines the sorting of the object. You'll probably need to play around with it until you find a point that works well for your sprites.
#3
I added a step to my scene update function to sort all the moveable sprites into different layers based on their Y position. Had no idea it could be done automatically - definitely have to check this out!
Does it look at individual tiles, or a whole tileset as one object? (thinking non-tiled object moving over static tiles)
12/08/2008 (12:57 pm)
Boy, I wish I knew THIS before I finished my game!I added a step to my scene update function to sort all the moveable sprites into different layers based on their Y position. Had no idea it could be done automatically - definitely have to check this out!
Does it look at individual tiles, or a whole tileset as one object? (thinking non-tiled object moving over static tiles)
#4
12/09/2008 (6:40 am)
Thanks I will give this a go.
Torque Owner Shaderman
With layers. If you need to change the layer from code, you can use setLayer.