Skip to main content
GameDev.net gamedev.net
🔒 Locked

Sprite class example...

Started by demiurgeinc Mar 20, 2005 at 9:10 AM 4 replies 1.2k views
Original Post
demiurgeinc
demiurgeinc
Can someone provide me with a working example of using the sprite class to draw a texture? I've been mucking with the bits and pieces of code I've been able to find, but can't get my texture to draw. I was able to load the texture onto a triangle using SetTexture and DrawPrimitives, but my sprite code just doesn't want to work: device.BeginScene(); sprite.Begin( SpriteFlags.None ); Rectangle srcRect = new Rectangle(0,0, 90,90); Rectangle destRect = new Rectangle(0,0, 90,90); sprite.Draw2D(spaceship, srcRect, destRect, new Point(20,20), Color.White); sprite.End(); device.EndScene(); Any help would be most appreciated. Thanks.
Stukey
Stukey
I didn't test your code, but it doesn't look obviously wrong, try running the compiled version of your program (not in the debugger) and if the sprites show on that it means you should go into control panel>directx and change to the debug version of directx.
circlesoft
circlesoft
What is showing up? Or is nothing showing up at all?

Right now, you are modulating by a color of white. Try specifying Color.Transparent to maintain the original. Also, here is some example source to compare yours with:

sprite.Begin(SpriteFlags.None);sprite.Draw2D(texture, Rectangle.Empty, Rectangle.Empty,              new Point(5.0f, 5.0f), Color.White);sprite.End();
demiurgeinc
demiurgeinc
Thanks stukey that was it. Now although it should make sense to me, why wasn't it working with the retail version executed from within VS.NET?
Stukey
Stukey
Couldn't tell you in technical terms, I figured that out myself messing around because I had the same problem.

Topic Locked

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

Sign in to reply to this topic.