Jump to content
  • Advertisement
Sign in to follow this  
Ultimar235

Translating Sprites?

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

Hello, Sorry i'm a bit new to directx. I followed a tutorial about how to draw sprites to the screen which i found useful. But i can't seem to work out how to translate a sprite using the same matrix as i use for every other translation. E.g. if i translate a box by 10 and the sprite by 10, they do not end up in the same place. Below is the code i use at the moment. D3DXVECTOR3 vCenter( 0.0f, 0.0f, 0.0f ); D3DXVECTOR3 vPosition( 10.0f, 0.0f, 0.0f ); g_pSprite->Begin( D3DXSPRITE_ALPHABLEND ); g_pSprite->Draw( g_pTexture,&srcRect,&vCenter,&vPosition, D3DCOLOR_COLORVALUE(1.0f,1.0f,1.0f,1.0f) ); Any help is most appreciated :)

Share this post


Link to post
Share on other sites
Advertisement
use g_pSprite->SetTransform( D3DXMatrix ). You can make multiple calls inbetween Draw()'s to draw multiple sprites.

For example:


g_pSprite->Begin( D3DXSPRITE_ALPHABLEND );

g_pSprite->SetTransform( someMatrix );
g_pSprite->Draw( g_pTexture,&srcRect,&vCenter,&vPosition, D3DCOLOR_COLORVALUE(1.0f,1.0f,1.0f,1.0f) );

g_pSprite->SetTransform( anotherMatrix );
g_pSprite->Draw( g_pTexture,&srcRect,&vCenter,&vPosition, D3DCOLOR_COLORVALUE(1.0f,1.0f,1.0f,1.0f) );

g_pSprite->End();



For 'someMatrix' you may want to generate it using D3DXMatrixTransformation().

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!