Jump to content
  • Advertisement
Sign in to follow this  
Piranjah

[.net] Sprites and Z-axis

This topic is 4382 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!