Sign in to follow this  

[.net] Sprites and Z-axis

This topic is 4166 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, Im' pretty new at DirectX so my apologies if this is a stupid question :-s I'm making a cardgame with some animation and I'm using managed DirectX. I'm used to doing this kind of stuff in QT, but I'm trying to switch to .NET. What I want to do, is to be able to index the z-value. In QT you can draw a sprite and the z-index states if you want a certain sprite in front of another one. Now I'm trying to do this in MDX but I just don't get it yet:-s I can draw the sprites & such, and i can set the position (using a Vector3) but it seems the sprites get in front of eachother according to the drawing order, meaning the first drawn sprite is covered by all others? Isn't there a simple way to change this? I was hoping to be able to set the position and edit the Z-value, but this doesn't seem to be working. Any suggestions? Many thanks, Pascal

Share this post


Link to post
Share on other sites
Well just changing the Z coordinate won't work unless you applying transformations to either the Sprite or the World. You will also need to use a depth buffer to make sure pixels are occluded correctly.

A simpler solution might be to just give them a z coordinate value, and then sort them based on that value. Then they will be drawn in the correct order.

Share this post


Link to post
Share on other sites
Ok, it works, I didn't know I had to manually enable the Z-buffer. I was already placing them correct, but with no options for the z-buffer. Now it works:-)

Many thanks for the info!

Share this post


Link to post
Share on other sites

This topic is 4166 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this