本文整理汇总了C++中TextureManager::loadTileSetFromTexture方法的典型用法代码示例。如果您正苦于以下问题:C++ TextureManager::loadTileSetFromTexture方法的具体用法?C++ TextureManager::loadTileSetFromTexture怎么用?C++ TextureManager::loadTileSetFromTexture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextureManager
的用法示例。
在下文中一共展示了TextureManager::loadTileSetFromTexture方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildWorldFromInfo
bool TMXMapImporter::buildWorldFromInfo(Game *game)
{
TextureManager *worldTextureManager = game->getGraphics()->getWorldTextureManager();
if (mapType == MapType::ORTHOGONAL_MAP)
{
World *world = game->getGSM()->getWorld();
int largestLayerWidth = 0;
int largestLayerHeight = 0;
// LET'S FIRST FIGURE OUT THE WORLD WIDTH AND HEIGHT
// FIRST THE IMAGE LAYERS
map<string, ImageLayerInfo>::const_iterator iliIt = imageLayerInfos.begin();
while (iliIt != imageLayerInfos.end())
{
string key = iliIt->first;
ImageLayerInfo ili = imageLayerInfos[key];
if (ili.imagewidth > largestLayerWidth)
largestLayerWidth = ili.imagewidth;
if (ili.imageheight > largestLayerHeight)
largestLayerHeight = ili.imageheight;
iliIt++;
}
// AND THE TILED LAYERS
map<string, TiledLayerInfo>::const_iterator tliIt = tiledLayerInfos.begin();
while (tliIt != tiledLayerInfos.end())
{
string key = tliIt->first;
TiledLayerInfo tli = tiledLayerInfos[key];
int layerWidth = tli.width * tli.tileSetInfo->tilewidth;
if (layerWidth > largestLayerWidth)
largestLayerWidth = layerWidth;
int layerHeight = tli.height * tli.tileSetInfo->tileheight;
if (layerHeight > largestLayerHeight)
largestLayerHeight = layerHeight;
tliIt++;
}
unsigned int idOffset = worldTextureManager->getWStringTable()->getNumWStringsInTable();
// FIRST LOAD ALL THE TILE SETS
map<string, TileSetInfo>::const_iterator tsiIt = tileSetInfos.begin();
while (tsiIt != tileSetInfos.end())
{
string key = tsiIt->first;
TileSetInfo tsi = tileSetInfos[key];
wstring sourceImageW(tsi.sourceImage.begin(), tsi.sourceImage.end());
bool success = worldTextureManager->loadTileSetFromTexture(game, dir, sourceImageW, tsi.tilewidth, tsi.tileheight);
if (!success) return false;
tsiIt++;
}
// NOW LOAD THE IMAGE LAYERS, IF THERE ARE ANY
iliIt = imageLayerInfos.begin();
while (iliIt != imageLayerInfos.end())
{
string key = iliIt->first;
ImageLayerInfo ili = imageLayerInfos[key];
TiledLayer *imageLayerToAdd = new TiledLayer( 1,
1,
ili.imagewidth,
ili.imageheight,
0,
ili.collidable,
largestLayerWidth,
largestLayerHeight);
world->addLayer(imageLayerToAdd);
Tile *imageTile = new Tile();
imageTile->collidable = ili.collidable;
wstring imageSourceW(ili.imageSource.begin(), ili.imageSource.end());
imageTile->textureID = worldTextureManager->loadTexture(dir + imageSourceW);
imageLayerToAdd->addTile(imageTile);
iliIt++;
}
// AND NOW LOAD THE TILED LAYERS, WHICH REFERENCE THE TILE SETS
tliIt = tiledLayerInfos.begin();
while (tliIt != tiledLayerInfos.end())
{
// @TODO WE'LL NEED TO CUSTOMIZE THIS
bool collidableLayer = false;
string key = tliIt->first;
TiledLayerInfo tli = tiledLayerInfos[key];
TiledLayer *tiledLayerToAdd = new TiledLayer( tli.width,
tli.height,
tli.tileSetInfo->tilewidth,
tli.tileSetInfo->tileheight,
0,
tli.collidable,
largestLayerWidth,
largestLayerHeight);
world->addLayer(tiledLayerToAdd);
// WE HAVE TO ADD ALL THE TILES
int row = 0;
int col = 0;
int uncollidableIndex = tli.tileSetInfo->firstgid;
//.........这里部分代码省略.........
示例2: buildWorldFromInfo
bool TMXMapImporter::buildWorldFromInfo(Game *game)
{
TextureManager *worldTextureManager = game->getGraphics()->getWorldTextureManager();
if (mapType == MapType::ORTHOGONAL_MAP)
{
World *world = game->getGSM()->getWorld();
// LET'S FIRST FIGURE OUT THE WORLD WIDTH AND HEIGHT
calculateWorldDimensions();
// AND MAKE THE WORLD DIMENSIONS THE
// SIZE OF THE LARGEST LAYER
world->setWorldWidth(largestLayerWidth);
world->setWorldHeight(largestLayerHeight);
// IT'S POSSIBLE THE TEXTURE MANAGER ALREADY HAS SOME
// IMAGES, SO WE NEED TO KNOW HOW MANY IMAGES ARE ALREADY
// THER TO OFFSET THE IDS OF ALL IMAGE REFERENCES
unsigned int idOffset = worldTextureManager->getWStringTable()->getNumWStringsInTable();
// NOW LOAD THE TILE SETS IN THE ORDER THEY WERE LISTED
// INSIDE TMX FILE
list<TileSetInfo>::iterator tsiIt = tileSetInfos.begin();
while (tsiIt != tileSetInfos.end())
{
TileSetInfo tsi = (*tsiIt);
wstring sourceImageW(tsi.sourceImage.begin(), tsi.sourceImage.end());
bool success = worldTextureManager->loadTileSetFromTexture(game, dir, sourceImageW, tsi.tilewidth, tsi.tileheight, tsi.spacing, tsi.margin);
if (!success) return false;
tsiIt++;
}
// NOW LOAD ALL THE LAYERS
list<LayerInfo*>::iterator it = layerInfos.begin();
while (it != layerInfos.end())
{
LayerInfo *layer = (*it);
if (layer->type == LayerType::IMAGE)
{
ImageLayerInfo *ili = (ImageLayerInfo*)layer;
buildImageLayer(game, ili, idOffset);
}
else if (layer->type == LayerType::TILED)
{
TiledLayerInfo *tli = (TiledLayerInfo*)layer;
buildTiledLayer(game, tli, idOffset);
}
else if (layer->type == LayerType::SPARSE)
{
SparseLayerInfo *sli = (SparseLayerInfo*)layer;
buildSparseLayer(game, sli, idOffset);
}
// ON TO THE NEXT LAYER
it++;
}
}
if (mapType==MapType::ISOMETRIC_MAP){
World *world = game->getGSM()->getWorld();
// LET'S FIRST FIGURE OUT THE WORLD WIDTH AND HEIGHT
calculateWorldDimensions();
// AND MAKE THE WORLD DIMENSIONS THE
// SIZE OF THE LARGEST LAYER
world->setWorldWidth(largestLayerWidth);
world->setWorldHeight(largestLayerHeight);
// IT'S POSSIBLE THE TEXTURE MANAGER ALREADY HAS SOME
// IMAGES, SO WE NEED TO KNOW HOW MANY IMAGES ARE ALREADY
// THER TO OFFSET THE IDS OF ALL IMAGE REFERENCES
unsigned int idOffset = worldTextureManager->getWStringTable()->getNumWStringsInTable();
// NOW LOAD THE TILE SETS IN THE ORDER THEY WERE LISTED
// INSIDE TMX FILE
list<TileSetInfo>::iterator tsiIt = tileSetInfos.begin();
while (tsiIt != tileSetInfos.end())
{
TileSetInfo tsi = (*tsiIt);
wstring sourceImageW(tsi.sourceImage.begin(), tsi.sourceImage.end());
bool success = worldTextureManager->loadTileSetFromTexture(game, dir, sourceImageW, tsi.tilewidth, tsi.tileheight, tsi.spacing, tsi.margin);
if (!success) return false;
tsiIt++;
}
// NOW LOAD ALL THE LAYERS
list<LayerInfo*>::iterator it = layerInfos.begin();
while (it != layerInfos.end())
{
LayerInfo *layer = (*it);
if (layer->type == LayerType::IMAGE)
{
ImageLayerInfo *ili = (ImageLayerInfo*)layer;
buildImageLayer(game, ili, idOffset);
}
else if (layer->type == LayerType::TILED)
{
TiledLayerInfo *tli = (TiledLayerInfo*)layer;
//.........这里部分代码省略.........