Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Port to 2.0 problems  (Read 2270 times)

0 Members and 1 Guest are viewing this topic.

Xyro

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
Port to 2.0 problems
« 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 :



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 :



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);
            }
        }

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Port to 2.0 problems
« Reply #1 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).
Laurent Gomila - SFML developer

Xyro

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
Port to 2.0 problems
« Reply #2 on: April 18, 2011, 01:31:17 pm »
Thanks for the fast response, both problems are fixed !

 

anything