Jump to content
  • Advertisement
Sign in to follow this  
storage

[.net] MDX: Problem using sprites.

This topic is 4490 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

Hello! I have some problems with the drawing of sprites in Managed DirectX. This is how I currently draw the sprites, but it doesn't work. It throws "NullReferenceException". I think it's because _texture.ImageInformation.Width/Height doesn't return the size of the texture.
System.Drawing.Rectangle rect = new System.Drawing.Rectangle( 0, 0, _texture.ImageInformation.Width, _texture.ImageInformation.Height );
System.Drawing.SizeF size = new System.Drawing.SizeF( ( float ) _texture.ImageInformation.Width, ( float ) _texture.ImageInformation.Height );

_sprite.Draw2D( _texture, rect, size, position, System.Drawing.Color.White );

To me, it doesn't look like this is how you are supposed to use the sprite class, so I'm asking for some help to solve this. Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
Try using the Sprite.Draw() function a la:
Sprite.Draw(texture, sourceRect, center, position, Color.White.ToArgb());

SourceRect is a System.Drawing.Rectangle in which I specify a rectangle WITHIN the texture. If I set this argument to null, the entire texture it drawn.

Toolmaker

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!