SFML community forums
Bindings - other languages => DotNet => Topic started by: Xyro on April 17, 2011, 11:04:05 pm
-
I am porting my code over from 1.6 to 2.0 and I have 2 pretty weird problems.
One :
(http://i.cubeupload.com/m1o37c.png)
For some reason at a certain height some of my tiles are getting cut off and then a line is added to the bottom(you can see in the next picture how its normaly)
Two :
(http://i.cubeupload.com/wfx7HY.png)
Did something change to subrect ? with the exact same animation code that cuts a piece of the image to show the animation it bugs and shows more then needed.
Drawing code
public void DrawSprite(Sprite sprite, Vector2 position, Rectangle subRectangle)
{
if (viewPort.Intersects(new Rectangle(position.X - subRectangle.X, position.Y - subRectangle.Y, sprite.Width, sprite.Height)))
{
sprite.Position = position - new Vector2(viewPort.X, viewPort.Y);
sprite.SubRect = new IntRect((int)subRectangle.X, (int)subRectangle.Y, (int)(subRectangle.X + subRectangle.Width), (int)(subRectangle.Y + subRectangle.Height));
Program.renderImage.Draw(sprite);
}
}
-
For some reason at a certain height some of my tiles are getting cut off and then a line is added to the bottom
This may happen if your sprites are not drawn at integer coordinates.
Did something change to subrect ?
Rectangles are defined as (left, top, width, height) instead of (left, top, right, bottom).
-
Thanks for the fast response, both problems are fixed !