Skip to main content
gamedev.net
🔒 Locked

[.net] MDX: Problem using sprites.

Started by storage 0 replies 800+ views
Original Post
storage
storage
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!
Toolmaker
Toolmaker
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
 

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.