Game Development Community

Z-ordering sprites based on y position

by Graeme Sales · in Torque Game Builder · 01/04/2008 (8:44 am) · 5 replies

Hi all!

This is my first post on the forums so try to be gentle with me :D.

I'm in the middle of prototyping a game in TGB but have run up against a small problem when ordering sprites. The aim is to create a 2d scrolling beat-em-up style game similar to the likes of Golden Axe, Streets of Rage, Final Fight etc. Unfortunately this requires dynamically layering the sprites involved in the scene based on their y position, so that characters higher up are drawn behind other characters.

Does anyone know if there's an option to achive this automatically in TGB or will I have to write a sort algorithm to handle it myself?

Heres hoping someone's come up against this one before, it's been driving me crazy!

About the author

Recent Threads


#1
01/04/2008 (10:12 am)
There is indeed a way to do this in TGB. With no objects selected, go to the edit pane so you can get to the scene properties. Use the Layer Management rollout to set the sort order of one or more of your layers to "Y Axis" (or maybe -Y Axis, I don't remember). Then all the objects in that layer will be rendered in order based on their Y position. And you can edit the Sort Point on each object to control where it's sorted by (e.g. you might want to put the sort point on a person's feet, and the bottom of an obstacle).
#2
01/04/2008 (11:34 am)
Golden Axe, awesome.
#3
01/05/2008 (8:09 am)
Just tried it and it works perfectly! Who'd have thought the functionality would just be sitting there ready to use!

Thanks so much for your help on this Dan, it has definitely sold me on using the engine for my prototype.
#4
01/05/2008 (10:01 am)
Prototyping but not actually using it to program the game in? why not?
#5
01/06/2008 (9:15 am)
Assuming the prototype goes to plan I'll almost certainly use TGB to write the full game, but I'm a long way from that at the moment.

I figure I'd best learn to walk before I can run :)