I have loaded a sprite into memory like so:
Code:
HRESULT CDirectX::LoadSprite (TCHAR* szFilename, _Sprite* sprite) {
HRESULT hr;
// Load the texture from file
if(FAILED(hr = D3DXCreateTextureFromFileEx(_D3dDevice, szFilename,0,0,0,0,
D3DFMT_UNKNOWN,
D3DPOOL_MANAGED, D3DX_DEFAULT,
D3DX_DEFAULT,
D3DCOLOR_XRGB(192,192,192), NULL,
NULL, &(sprite- >lpD3dTexture))))
return hr;
if(FAILED(hr = D3DXCreateSprite(_D3dDevice, &(sprite->lpD3dSprite) )))
return hr;
return S_OK;
}
I have then attempted to rotate the sprite like this:
Code:
D3DXMatrixRotationY(&marioSprite.d3dMario , radian);
where d3dMario is a D3DXMATRIX and radian is just a float.
I then render the sprite like this:
Code:
if(SUCCEEDED(marioSprite.Mario[marioSprite.currentMario].lpD3dSprite ->Begin(D3DXSPRITE_ALPHABLEND))) {
marioSprite.Mario[marioSprite.currentMario].lpD3dSprite ->SetTransform(&marioSprite.d3dMario);
marioSprite.Mario[marioSprite.currentMario].lpD3dSprite->Draw
(marioSprite.Mario[marioSprite.currentMario].lpD3dTexture ,
NULL, NULL, &D3DXVECTOR3
(marioSprite.xPos ,marioSprite.yPos ,
0.0f),D3DCOLOR_XRGB
(192,192,192));
marioSprite.Mario[marioSprite.currentMario].lpD3dSprite ->End ();
}
Unfortunately when I draw the sprite it disappears off the screen!!!!!!! I know you can rotate primatives around the y-axis. Am I simply just barking up the wrong tree here trying to do it with 2D sprites?
BTW the code works fine without the attempt at rotating it, unfortunately the sprite only faces forward. To add the animation I simply just toggled between pictures forcing the sprite to appear to walk, hence all the variable mumbo jumbo.
If it can't be done I guess I will simply just add more pictures to toggle between. I was just trying not to do that.
[edit]
well I decided to do the add more pictures thing, that way I could keep messing around with this whole DirectX deal. Still, any information will be greatly accepted. Merry Christmas and Happy New Year everybody.
[/edit]