Reposted with the use of D3DXSPRITE object.

CSprite.h
[PHP]
#pragma once
#include "d3d9.h"
#include "d3dx9.h"
#include "rectTools.h"
#include "windows.h"
class CSprite {
private:
RECT srcSize;
unsigned int switchTime;
unsigned int currentFrame;
unsigned int numberOfPics;
unsigned long savedMil;
LPDIRECT3DDEVICE9 d3dDev;
LPD3DXSPRITE hSpriteHandler;
LPDIRECT3DTEXTURE9 texture;
D3DXIMAGE_INFO imgInfo;
D3DXVECTOR3 location;
public:
CSprite();
virtual int init(LPD3DXSPRITE srcSpriteHandler, RECT &srcSize, char* path, int srcNumberOfPics, int srcSwitchTime, D3DXVECTOR3 srcLocation);
virtual void Render();
};[/PHP]
CSprite.cpp
[PHP]

#include "stdafx.h"
#include "CSprite.h"

CSprite::CSprite() {
}
int CSprite::init(LPD3DXSPRITE srcSpriteHandler, RECT &size, char* path, int srcNumberOfPics, int srcSwitchTime, D3DXVECTOR3 srcLocation) {

//Param analyzation
switchTime = srcSwitchTime;
numberOfPics = srcNumberOfPics;
srcSize = RECT(size);
savedMil = GetTickCount() + srcSwitchTime;

hSpriteHandler = srcSpriteHandler;
location = D3DXVECTOR3(srcLocation);


//Mempreset
memset(&texture, 0, sizeof(texture));
HRESULT res = hSpriteHandler->GetDevice(&d3dDev);
if(res != D3D_OK) {
MessageBoxA(0, "Error, unable to create sprite handle", "error", MB_OK);
return -1;
}

D3DXGetImageInfoFromFileA(path, &imgInfo);
res = D3DXCreateTextureFromFileExA(d3dDev,
path,
imgInfo.Width,
imgInfo.Height,
1,
D3DPOOL_DEFAULT,
D3DFMT_UNKNOWN,
D3DPOOL_DEFAULT,
D3DX_DEFAULT,
D3DX_DEFAULT,
D3DCOLOR_XRGB(255,0,255),
&imgInfo,
NULL,
&texture);

if(res != D3D_OK) {
MessageBoxA(0, "Error Creating TextureHandle", "error", MB_OK);
return -1;
}

return 1;
}

void CSprite::Render() {
if(GetAsyncKeyState(VK_RIGHT)&0x8000)
location.x++;
else if(GetAsyncKeyState(VK_DOWN)&0x8000)
location.y++;


if(GetTickCount() > savedMil) {
currentFrame++;
savedMil = GetTickCount() + switchTime;
}

int fNumber = currentFrame % numberOfPics;
RECT sourceRect;
sourceRect.left = srcSize.right * fNumber;
sourceRect.right = sourceRect.left + srcSize.right;
sourceRect.top = 0;
sourceRect.bottom = sourceRect.top + srcSize.bottom;


D3DXVECTOR3 centerPoint;
centerPoint.x = (float)srcSize.right / 2;
centerPoint.y = (float)srcSize.bottom / 2;
centerPoint.z = 0;



if(hSpriteHandler->Begin(D3DXSPRITE_ALPHABLEND)){
D3DXMATRIX rotation;
rotation. = 50.0f;
hSpriteHandler->SetTransform(new D3DXMATRIX(&rotation));
hSpriteHandler->Draw(texture, &sourceRect, &centerPoint, &location, D3DCOLOR_ARGB(255,255,255,255));

hSpriteHandler->End();
} else {
int i;
return;
}
}[/PHP]