SFML community forums

Bindings - other languages => DotNet => Topic started by: Xyro on April 17, 2011, 11:04:05 pm

Title: Port to 2.0 problems
Post 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
Code: [Select]


        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);
            }
        }
Title: Port to 2.0 problems
Post by: Laurent on April 18, 2011, 07:48:30 am
Quote
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.

Quote
Did something change to subrect ?

Rectangles are defined as (left, top, width, height) instead of (left, top, right, bottom).
Title: Port to 2.0 problems
Post by: Xyro on April 18, 2011, 01:31:17 pm
Thanks for the fast response, both problems are fixed !