Tag Info

New answers tagged

1

As far as I know, this is possible using the sf::Image class: sf::Image spritesheet; spritesheet.loadFromFile("spritesheet.png"); int currentSprite = 2; sf::Texture texture; texture.loadFromImage (spritesheet, currentSprite*spriteWidth, spriteHeight); sf::Sprite sprite; sprite.setTexture(texture); If you do this in a for-loop, you could create a fluent ...


0

Put all your frames into 1 image, then load that image into an sf::Texture. In your spritesheet class, have that texture (or a ref to it) as a member along with an array (vector) of sf::IntRect objects, which each represent the parts of the texture that the frames are from. When you want to draw a frame from your spritesheet, create a temporary sf::Sprite ...


0

you can simply use the box2d editor to match your sprite sheet with the body fixture there is a powerful application who do this for you : LINK you can : Automatically decomposes concave shapes into convex polygons, Automatically traces your images if needed, Supports multiple outlines for a single body, Supports polygon and circle shapes, Reference ...


0

If you arent going (or can't because of software limitations) to remove the extra pixels you could go into the original sprite sheet and move the image of the crouching soldier down. The problem is that you won't have accurate collision detection if you are keeping those extra pixels so crouching might be useless.


1

Yes - you can use the Marching Squares algorithm to detect the bounds of the image within the frame, and then I would suggest storing the actual bounds (height/width) somewhere. Particularly if your sprites contain islands, as this can take a long time to locate all the little pieces in the frame. Ideally, you would repack your spritesheets into an atlas so ...



Top 50 recent answers are included