Samuli Lehtonen
Samuli Lehtonen

Reputation: 3860

Using tiles in SFML and collision detection

I decided to look a good tileset to use and found some, but the question is how I actually load the tile from the image file as there seem to be more than one tile in one file?

Also how do I implement a collision detection for non square tiles?

Example: Tileset

Upvotes: 1

Views: 1068

Answers (1)

bobbaluba
bobbaluba

Reputation: 3884

Images(sfml1.6) or Textures (sfml2.0) are usually drawn using sf::Sprite. The usual way to do it is to let all sprites share the same tileset texture/image, and then use sf::Sprite::SetSubRect(const IntRect &SubRect) to set the area of the texture that should be drawn.

The Sprite class in the sfml API is probably a good place to start

Upvotes: 1

Related Questions