D3DXSprite and showing textures and rotating them in different ways
i have many textures to show on the screen, some of these textures may have rotation or other transformation. All transformation indepen开发者_运维技巧dent. Do i need to create D3DXSprite for every independent texture? Because, if i create only one sprite and apply transformation it have an affect for every texture in the sprite. Thanks.
No, as the documentation to ID3DXSprite::Draw() states:
To scale, rotate, or translate a sprite, call ID3DXSprite::SetTransform with a matrix that contains the scale, rotate, and translate (SRT) values, before calling ID3DXSprite::Draw. For information about setting SRT values in a matrix, see Matrix Transforms.
So it would look something like this:
d3dxSpriteObject.Begin([...]);
for(int i=0; i<numTextures; i++)
{
d3dxSpriteObject.SetTransform(matrix);
d3dxSpriteObject.Draw(texture[i], NULL, textureCenter[i], texturePos[i], 0xffffffff);
}
d3dxSpriteObject.End();
精彩评论