Sign in to follow this  
marshdabeachy

Sprite Z-Order

Recommended Posts

marshdabeachy    100
Beginner question... how do I go about setting the z-order for sprites being positioned with a D3DVECTOR2 position? I know a D3DVECTOR3's z parameter will be used as depth, but I'm doing 2D matrix transformations and can't use the third parameter. Or would prefer not to use it, anyway, since it'd muck up my stuff.

Share this post


Link to post
Share on other sites
marshdabeachy    100
Okay, well then I'm still stuck. I'm trying to sort all the sprites by their distance to the camera, so I can draw them in the correct order. Of course it's being a pain and not working.

In my render function, I stuffed the sprite info into a vector:

std::sort(spriteSort.begin(), spriteSort.end(), compare);


The compare function:

bool compare(spriteInfo* a, spriteInfo* b) {
return a->distToCamera < b->distToCamera;
}


I ran debug on it, the compare function is being called. There are no errors or warnings. Everything is supposed to be perfect. But it's not sorting. I run through the vector afterward, and it's like I didn't even call sort. It does nothing to it.

Uh... what?

Share this post


Link to post
Share on other sites

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