问题
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:
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
- http://www.sfml-dev.org/documentation/2.0/classsf_1_1Sprite.php
- http://www.sfml-dev.org/documentation/1.6/classsf_1_1Sprite.php
来源:https://stackoverflow.com/questions/10321812/using-tiles-in-sfml-and-collision-detection