먼저 스프라이트 객체 입니다.
struct SPRITE
{
int rows, cols; // number of rows and columns
int width, height; // width and height of each frame
LPDIRECT3DTEXTURE9 tex; // texture
};
이 함수는 스프라이트를 로드하는 함수 입니다.
void LoadSprite(SPRITE* pSprite, LPCTSTR File, int width, int height, int cols, int rows)
{
D3DXCreateTextureFromFileEx(d3ddev,
File,
D3DX_DEFAULT,
D3DX_DEFAULT,
D3DX_DEFAULT,
NULL,
D3DFMT_A8R8G8B8,
D3DPOOL_MANAGED,
D3DX_DEFAULT,
D3DX_DEFAULT,
D3DCOLOR_XRGB(255, 0, 255),
NULL,
NULL,
&pSprite->tex);
pSprite->width = width;
pSprite->height = height;
pSprite->cols = cols;
pSprite->rows = rows;
return;
}
이 함수는 스프라이트를 뿌려주는 함수입니다.
void DrawSpriteNA(SPRITE* pSprite, float x, float y, float z, int alpha)
{
RECT FrameBox;
FrameBox.top = x;
FrameBox.left = y;
FrameBox.right = pSprite->width;
FrameBox.bottom = pSprite->height;
D3DXVECTOR3 position(x, y, z);
d3dspt->Draw(pSprite->tex, &FrameBox, NULL, &position, D3DCOLOR_ARGB(alpha, 255, 255, 255));
}
실제사용은
SPRITE sakura;
LoadSprite(&sakura, TEXT("sakucopy.png"), 250,350 , 1, 1);
이렇게 로드하고
렌더사이에
DrawSpriteNA(&sakura, 250,350, 0,255);
이렇게 넣습니다.
이렇게 하면..
아래와 같은 화면이 나와야 하지만..
----------------------------------- 추가합니다. 실제 실행화면 입니다.-------------------------------------------------------------------
보시면 길어보입니다... ㅡ_ㅡ;;;
뭔가 스케일 문제 같은데.. 원인을 모르겠습니다.
죄송하지만 해결방법좀 부탁드리겠습니다. ㅜㅜ