Jump to content
  • Advertisement
Sign in to follow this  


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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am using C++ and Direct3D9. Using D3DXSprite, how do you set a sprites position? When you use D3DXFont with D3DXSprite, how do you specify the position of the text? I want to specify the z value, so that I can make a sprite appear in front of text or vice versa. Anyone know? Someone must. I need answers :)

Share this post

Link to post
Share on other sites
The structure of the ID3DXSprite interface states that ID3DXSprite::Draw() method will give you a parameter called CONST D3DXVECTOR3 * pPosition that is used to define where the sprite is in screen space (default) but you could change this and when you begin the rendering of the sprite you can state D3DXSPRITE_OBJECTSPACE.

The world, view, and projection transforms are not modified. The transforms currently set to the device are used to transform the sprites when the batched sprites are drawn (when Flush or End is called). If this flag is not specified, then world, view, and projection transforms are modified so that sprites are drawn in screen-space coordinates.

Also for ID3DXFont, ID3DXFont::DrawText() gives you the parameter LPRECT pRect that lets you specify a rectangle to render the text into.

But... with all that said, if you are rendering the sprite before you render the text, your text should appear ontop of your sprite.

simple example

//Render your sprite
using (Sprite sprite = new Sprite(renderer.Device))
sprite.Draw(texture, new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.0f, 0.0f), Color.White.ToArgb());
//Render your text
debug.Display("Frames per second: " + timer.FPS.ToString(), 16, Color.Yellow);

I hope this helps.
Take care.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!