title: DirectX Sprite renders in a different position when scaled
body: <p>Currently making some UI classes and UI elements for a game and am coming across an issue when scaling sprites using DirectX 9.</p>
  
  <p>So at the moment I have a <code>ID3DXSprite*</code> object (<code>m_barImage</code>) which is a health bar.  Obviously as the player health changes, the health bar needs to get longer/shorter.</p>
  
  <p>So I have this in my <code>Update()</code> function</p>
  
  <pre><code>  // Calculate the width of the bar taking into account the health amount
    float width = (m_maxWidth / 100.0f) * m_percentageFull;
  
    // compare last width with m_currentWidth to get a scaling ratio
    float resizeRatio = width / m_currentWidth;
    m_currentWidth = width;
  
    Matrix scaleMatrix;
    D3DXMatrixScaling(&amp;scaleMatrix, resizeRatio, 1.0f, 1.0f);
    m_barImage-&gt;SetTransform(&amp;scaleMatrix);
  </code></pre>
  
  <p>and in my <code>Render()</code> function I have </p>
  
  <pre><code>  m_barImage-&gt;Begin(NULL);
  
    m_barImage-&gt;Draw(m_texture, NULL, NULL, &amp;m_position, 0x007F17);
  
    m_barImage-&gt;End();
  </code></pre>
  
  <p>My problem is, as I scale the sprite down in size in the X axis, the position at which the sprite is rended moves to the left.</p>
  
  <p><strong>NOTE: <code>m_position</code> is the position of the sprite set in the constructor and is does NOT change</strong></p>
  
  <p>Something when scaling the sprite is changing the position at which it is rendered.</p>
  
  <p>Can anyone help?</p>