• 12
• 12
• 9
• 10
• 13

# scaling sprites

This topic is 4562 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Using directX9.0 and ID3DXSprite How can I scale sprites? Make them larger or smaller, without changing the actual bitmap file. this is the draw function HRESULT Draw( LPDIRECT3DTEXTURE9 pTexture, CONST RECT *pSrcRect, CONST D3DXVECTOR3 *pCenter, CONST D3DXVECTOR3 *pPosition, D3DCOLOR Color ); The old draw function had a scaling vector. Anyone have any suggestions?

##### Share on other sites
You can use the SetTransform() function to set a scaling transform. Something like this (untested):
D3DXMATRIX matView, matProj, matScale, matFinal;pDevice->GetTransform(D3DTS_VIEW,&matView);pDevice->GetTransform(D3DTS_PROJECTION,&matProj);D3DXMatrixScaling(&matScale,2.0f,0.5f,1.0f);matFinal = matScale*matView*matProj;pSprite->SetTransform(&matFinal);pSprite->Draw(...);
That should scale by 2.0 in X and 0.5 in Y. Z isn't used, so you'll usually want to set it to 1.0.
And you need the view and projection matrices, because SetTransform() wants a matrix to translate from world space to screen space, not from model space to world space (which you'd just set matScale for).