struct FIRE
{
int nCount;
int nIndex;
DWORD dwAniTime;
DWORD dwOldAniTime;
RECT *pRect;
D3DXVECTOR3 *pCenter;
};
FIRE g_sFire;
RECT g_rtFireRect[] = ; // 영역좌표
D3DXVECTOR3 g_vCenter[] = { D3DXVECTOR3(/* ... */)} // 중심좌표
이제 객체를 생성 후 초기화 하자
D3DXCreateSprite(pd3dDevice &g_Sprite /* ... */);
D3DXCreateTextureFromFileEx(pd3dDevice /* ... */);
g_sFire.nCount = 6;
g_sFire.nIndex = 0;
g_sFire.dwAniTime = 100;
g_sFire.dwOldAniTime = GetTickCount();
g_sFire.pRect = g_rtFireRect;
g_sFire.pCenter = g_vCenter;
애니메이션 데이터 갱신
DWORD dwCurTime = GetTickCount();
if(dwCurTime - g_sFire.dwOldAniTime >= g_sFire.dwOldAniTime)
{
g_sFire.dwOldAniTime = dwCurTime;
g_sFire.nIndex = ++g_sFire.nIndex % g_sFire.nCount;
}
출력하기
if(SUCCESSDED(pd3dDevice->beginScene()))
{
g_Sprite->Begin(D3DXSPRITE_ALPHABLEND);
g_Sprite->Draw(g_pTexture, &g_sFire.pRect[g_Fire.nIndex], /* ... */);
g_Sprite->End();
pd3dDevice->EndScene();
}
리셋과 해제
g_Sprite->OnLostDevice();
// DestoryDevice
g_Sprite->Release();
g_pTexture->Release();