I hope it's okay for me to bump this somewhat old topic, I rather not start another one, since my problem is exactly identical as described in lucasncv's first post.
I see that there is a kinda hackish solution to this, I am wondering if somebody knows some better way, since I am handling the sprite selection a bit differently.
I am using SFML 2.0.
I load the sprite sheets using sf::Texture mySpritesheet;
I make a sf::IntRect as the boundaries for the sprite, and initialize them in the following way:
if (size == 1)
{
orb_surf = orb1_sheet;
for (int i = 0; i < 5 ; i++)
{
orb1_sheet_sprite[i].Left = i*3;
orb1_sheet_sprite[i].Top = (type-1)*3;
orb1_sheet_sprite[i].Width = 3;
orb1_sheet_sprite[i].Height = 3;
}
}
My sprite is displayed in the following way:
orb_surf.SetTextureRect(orb1_sheet_sprite[sprite_count]);
orb_surf.SetPosition(x, y - camera.Top);
App.Draw(orb_surf);
In this specific example, there are 2 rows of 5 3x3 sprites.
top row for red, bottom for orange, and the x position is the different states of animation (flashing)
when the player is moving on the y axis, making the camera move, there are certain "sweet spots" where the red orb is displayed as top half red, bottom half orange, so the selection rectangle went down a pixel.
What would you guys advise?
Should I change all my sf::IntRects to sf::FloatRect and substract 0.0078125 from the borders?
Is there a cleaner way to do this?
Also, is there some advantage (performance-wise perhaps) of using gl calls, as shown in the post above mine, or sf::Rect is okay?