I created a image that with no scale would fill the hud's life bar to 100% because the bar is exactly the right size when drawn.
It works fine when the scale is 1.0 but at any other value it is not right.
It scales fine the problem is it is drawn in the wrong position.
instead of the it being drawn at
pos1.x = 12;
pos1.y = 768 - 48 + 24;
it looks like it is being drawn at this position
pos1.x = 6;
And then it over laps part of the HUD graphic.
I don't understand why its moving the sprite to the left.. It gets worse the more scale there is.
D3DXVECTOR3 pos1; pos1.x = 12; pos1.y = 768 - 48 + 24; pos1.z = 0; D3DXMATRIX scale_matrix; D3DXVECTOR2 scale(0.5f,1.0f); // 50% scale in then x-direciton only D3DXMATRIX original; sprite_obj->GetTransform(&original); D3DXMatrixTransformation2D(&scale_matrix,NULL,0,&scale,NULL,NULL,NULL); sprite_obj->SetTransform(&scale_matrix); window::sprite_obj->Draw( txt_manager.get_texture("hp"),NULL,NULL,&pos1, D3DCOLOR_XRGB(255,255,255)); sprite_obj->SetTransform(&original);
do i need to use a translation vector? If so how would i make it right every scale value?
Why is this happening?
Also how can i set the transparency of a sprite at run time before it is drawn?