Questions tagged [spritebatch]

Used in the XNA Framework. Enables a group of sprites to be drawn using the same settings.

SpriteBatch is a commonly used object for drawing 2D bitmaps in XNA. It allows developers to draw a sprite in their XNA Application, with a variety of options. It is included in Microsoft.Xna.Framework.Graphics

To start, you must initialize a SpriteBatch:

SpriteBatch batch1 = new SpriteBatch();

Now you can use batch1. To begin the SpriteBatch, call SpriteBatch.Begin() in your Draw method. Advanced users can add arguments as seen here.

Then you can draw a sprite with with the Draw(..) method.

SpriteBatch.Draw(Texture2D, Rectangle, Color);

That is the simplest of the SpriteBatch.Draw method, you can use other arguments such as Vector2 for position, and SpriteEffects. You can also draw text using SpriteFonts and the appropriate overload: SpriteBatch.DrawString (SpriteFont, String, Vector2, Color)

To end the SpriteBatch simply call SpriteBatch.End();

For more information, see the MSDN documentation for SpriteBatch.

184 questions
-1
votes
2 answers

Dragging a texture (without jump)

How can I drag a texture (image) without making it jump and centering itself on the mouse cursor (what I have below in my code)? When I click on the texture, nothing should happen, and when I drag, the mouse cursor should stay in place (relative to…
Alex
  • 839
  • 1
  • 12
  • 24
-1
votes
1 answer

MonoGame SpriteBatch.Draw() invalid arguments when there really aren't any invalid arguments?

I'm drawing a Sprite in MonoGame and I'm trying to use the Draw()-method with the overload that enables a SpriteEffect to be passed as an argument, but I get a red underline and it says: The best overloaded method match for…
-1
votes
1 answer

Drawing a class multiple times on the screen XNA

I am making a simple brick-breaker type game. I have a ball paddle class, and i have both moving around the screen fine. I also have a brick class, of a brick, that when it is hit with the ball it dissapears. Now i want multiple bricks on the screen…
HTML_guy
  • 1
  • 3
-4
votes
1 answer

"[AppName] has stopped" in my physical device. ERROR in logcat: java.lang.NullPointerException

I have been working on a game in android studio and libgdx and whenever I run it on my physical device it says "[AppName] has stopped". I have checked for the names of the images that i used (spelling, capitalization), other than that I have no…
1 2 3
12
13