Help with Sprite Manipulation

Started by
5 comments, last by Thors1982 17 years, 9 months ago
I have a few questions. And I wasn't really sure what the subject should be so hopefully it was good enoguh :-) I am writing a isometric game in directX 9, and I am using sprites of course to draw each tile. There are a few things I don't know how to do though, I am assuming there is a DirectX way to do both. 1: Flip a tile vertically I was only going to have a file with guys facing up-left and down-left, but if I could flip it with code I could also have them facing up-right and down-right. 2: Give a tile a Hue or color. My texture for the player is mostly grey/white/black, and I was thinking if I could color it with code I could have players choose their skin tone. Also could use this for multiple color trees and more. Hopefully I explained that well enough. Thanks in advance
Advertisement
(1) You can use ID3DXSprite::SetTransform() to do this kind of thing. Just compose your matrix (ie transformation, rotation, ect), then set it with this.

(2) The final parameter of ID3DXSprite::Draw() is a modulation color. You can use this to shade your textures.
Dustin Franklin ( circlesoft :: KBase :: Mystic GD :: ApolloNL )
Ok, i should have known the color one, i dunno what I was thinking. But I am having problems getting the Transform to work.

D3DXMATRIX start;D3DXMATRIX flip;D3DXMatrixIdentity(&flip);D3DXMatrixIdentity(&start);D3DXMatrixScaling(&flip, -1.0, 1.0, 1.0);D3DXMatrixMultiply(&start, &start, &flip);sprite->SetTransform(&start);


After I do that the sprite dissapears. Am I using the wrong transformation or is there something I just don't understand.
Quote:Original post by Thors1982
After I do that the sprite dissapears. Am I using the wrong transformation or is there something I just don't understand.


Does the sprite reappear if you disable Culling? (with SetRenderstate)
Stay Casual,KenDrunken Hyena
I actually turn off culling right after I initilize DirectX.

[Edited by - Thors1982 on July 6, 2006 4:09:44 PM]
Quote:Original post by Thors1982
After I do that the sprite dissapears. Am I using the wrong transformation or is there something I just don't understand.

Can you try a simpler transform first to see if that works? Something easy, like rotating 45 degrees or something.
Dustin Franklin ( circlesoft :: KBase :: Mystic GD :: ApolloNL )
Any transformation I do like shifts the character away from the center of the screen

if I do a D3DXMatrixRotationZ(&flip, .3);

or a D3DXMatrixScaling(&flip, .5, .5, 1.0);

the character moves, away from the center of the screen, so im assuming that when i did a -1 scaling it just moved the sprite off the screen. So obvioulsy I am not doing something right. I don't know why scaling something would change where the sprite is drawn.

This topic is closed to new replies.

Advertisement