Using tiles in SFML and collision detection

2019-07-26 08:34发布

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

1条回答
你好瞎i
2楼-- · 2019-07-26 09:04

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

查看更多
登录 后发表回答