本文整理汇总了C++中tmx::Map::getTilesets方法的典型用法代码示例。如果您正苦于以下问题:C++ Map::getTilesets方法的具体用法?C++ Map::getTilesets怎么用?C++ Map::getTilesets使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tmx::Map
的用法示例。
在下文中一共展示了Map::getTilesets方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rec
Map(std::vector<bool> &visible, const tmx::Map& source)
{
// Let's build tilesets
for(auto tileset : source.getTilesets())
tilesets.push_back(Tileset(tileset));
// The following part assumes we have only one tileset
unsigned tilesetwidth = tilesets[0].image.getSize().x / tilesets[0].tilewidth;
int i = 0;
for(auto layer : source.getLayers())
{
int j = 0;
layers.push_back(std::vector<Tile>());
visible.push_back(layer->getVisible());
for(auto tile : layer->getData())
{
// Position of the tile on the tileset
sf::Vector2i post(((tile.getId() - tilesets[0].firstgid) % tilesetwidth) * tilesets[0].tilewidth,
((tile.getId()-tilesets[0].firstgid) / tilesetwidth) * tilesets[0].tileheight
);
// Dimensions of the tile according to the tileset
sf::Vector2i dim(tilesets[0].tilewidth, tilesets[0].tileheight);
sf::IntRect rec(post, dim);
// Position of the tile on the view
sf::Vector2f pos((j % source.getWidth()) * tilesets[0].tilewidth, (j / source.getWidth()) * tilesets[0].tileheight);
layers[i].push_back(Tile(tilesets[0].image, rec, pos));
j++;
}
i++;
}
for(auto objectgroup : source.getObjectgroups())
{
layers.push_back(std::vector<Tile>());
for(auto object : *objectgroup)
{
// Position of the object on the tileset
sf::Vector2i post(((object.getId() - tilesets[0].firstgid) % tilesetwidth) * tilesets[0].tilewidth,
((object.getId()-tilesets[0].firstgid) / tilesetwidth) * tilesets[0].tileheight
);
// Dimensions of the object according to the tileset
sf::Vector2i dim(tilesets[0].tilewidth, tilesets[0].tileheight);
sf::IntRect rec(post, dim);
// Position of the tile on the view. Do NOT forget the offset due to Tile Map Editor positioning conventions.
sf::Vector2f pos(object.getX(),object.getY()-tilesets[0].tileheight);
layers[i].push_back(Tile(tilesets[0].image, rec, pos));
}
}
}