Sign in to follow this  

2D sprites and animation

This topic is 4059 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 there! Direct 3D 9 has this sweet ID3DXSprite-Class. But there's a thing I don't understand: When calling the .Draw() method I have to specify a RECT, which says what portion of the texture will be used for the sprite. And with an animated texture, this would be the perfect place for selecting different frames inside my texture, right? But the problem is that have to give exact, absolute pixel values (like 64x64). But if want to use this class for textures of all sizes, where I just know that it has e.g. 8 frames that won't work. Is there a way to use relative coordinates (like from 0.0f to 1.0f)? Thanks for your help!

Share this post


Link to post
Share on other sites
But how do I get the texture's width and height?
I've briefly looked at the D3D texture class, but it has no obvious attributes like width and height ;-)

Share this post


Link to post
Share on other sites
Use the GetLevelDesc function held in the IDirect3DTexture9 interface, pass in zero and a memroy address to a D3DSURFACE_DESC object. The D3DSURFACE_DESC structure contains the width and height of the texture.

That is from memory so I might be wrong, try it out and let me know how you get on.

Share this post


Link to post
Share on other sites

This topic is 4059 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