Quantcast
Channel: Community | MonoGame - Latest topics
Viewing all articles
Browse latest Browse all 6821

Unable to draw a sprite properly from a spritesheet

$
0
0

@LEM wrote:

I have a spritesheet with 2 sprites. Each sprite is 40x60. The total size of the image is 40x120. It looks like this (the red line is part of the 1st sprite). I'll tell you in a second why I added that.

It seems that for some reason, when trying to draw the second sprite, it will always take the last line of the previous sprite. I have drawn that red line to illustrate that.

This is my code that draws the 2nd sprite:

Rectangle rect = new Rectangle(0, 60, 40, 60); // Choose 2nd sprite
Vector2 pos = new Vector2(100, 100);
Vector2 origin = new Vector2(0, 0);

spriteBatch.Begin();
spriteBatch.Draw(mSpriteTexture, pos , rect, Color.White, 0.0f, origin, 6, SpriteEffects.None, 0.0f);
spriteBatch.End();

And this is how it looks when I run the program:

Any ideas what I'm doing wrong?

Note: For this example I'm using scale=6. I did this because it seems that when scale > 1 this problem will always happen. If scale = 1, it doesn't seem to happen all the time.

Posts: 6

Participants: 4

Read full topic


Viewing all articles
Browse latest Browse all 6821

Trending Articles