I have a player class here that inits the player and its sprite texture for drawing. The sprite map is 399x800, and each tile is 50x50. When I execute the program, the sprite is 64x64 instead of 50x50, so the sprite is cut off to the right and bottom. What can I do to draw this texture as 50x50?
Code:class Common { public: LPDIRECT3DTEXTURE9 spriteTexture; LPD3DXSPRITE sprite; D3DXVECTOR3 pos; RECT srcRect; D3DXVECTOR3 center; // Common Constructor Common(void) { } void Init(int x, int y, char *filepath) { // Set the sprite position in screen space. pos = D3DXVECTOR3(x, y, 1); hr = D3DXCreateTextureFromFileEx(pd3dDevice, filepath, D3DX_DEFAULT_NONPOW2, D3DX_DEFAULT_NONPOW2, 0, 0, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, D3DCOLOR_XRGB(255, 0, 255), NULL, NULL, &spriteTexture); if (FAILED(hr)) return; hr = D3DXCreateSprite(pd3dDevice, &sprite); if (FAILED(hr)) return; center = D3DXVECTOR3(0, 0, 0); srcRect.left = 0; srcRect.top = 0; srcRect.right = 50; srcRect.bottom = 50; } // Common Deconstructor ~Common() { D3D_SAFE_RELEASE(spriteTexture); D3D_SAFE_RELEASE(sprite); } void Draw() { sprite->Begin(0); sprite->Draw(spriteTexture, &srcRect, ¢er, &pos, D3DCOLOR_XRGB(255, 255, 255)); sprite->End(); } };



LinkBack URL
About LinkBacks


