• Advertisement
Sign in to follow this  

Help rotating a sprite D3D9

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

Hey GameDev

 

I've 2 sprites, an enemy and a guy, and I'm trying to rotate guy, but not enemy:

 

void Draw(LPD3DXSPRITE sprite, LPDIRECT3DDEVICE9 d3dDevice)
{
	sprite->Draw(texture, &enemy, &D3DXVECTOR3(0, 0, 0), &D3DXVECTOR3(400, 400, 0),                D3DCOLOR_ARGB(255,255,255,255));
	sprite->SetTransform(&matrix);
	sprite->Draw(texture, &guy, &D3DXVECTOR3(0, 0, 0), &guyPosition, D3DCOLOR_ARGB(255,255,255,255));
}

 

 

Problem is it rotates both of them, and I don't know why. Help?

Share this post


Link to post
Share on other sites
Advertisement
It looks like you need to reset the transformation after each draw call.
void Draw(LPD3DXSPRITE sprite, LPDIRECT3DDEVICE9 d3dDevice)
{
        D3DXMATRIX identity;
        D3DXMatrixIdentity(&identity);
	sprite->SetTransform(&identity);
	sprite->Draw(texture, &enemy, &D3DXVECTOR3(0, 0, 0), &D3DXVECTOR3(400, 400, 0),                D3DCOLOR_ARGB(255,255,255,255));
	sprite->SetTransform(&matrix);
	sprite->Draw(texture, &guy, &D3DXVECTOR3(0, 0, 0), &guyPosition, D3DCOLOR_ARGB(255,255,255,255));
}

Share this post


Link to post
Share on other sites

Thank you so much. I don't know why I didn't think of this, I just assumed that because I didn't have to do it in 3D transformations, I wouldn't have to for this. 

 

Thank you :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement