本文整理汇总了C++中TextureManager::getWStringTable方法的典型用法代码示例。如果您正苦于以下问题:C++ TextureManager::getWStringTable方法的具体用法?C++ TextureManager::getWStringTable怎么用?C++ TextureManager::getWStringTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextureManager
的用法示例。
在下文中一共展示了TextureManager::getWStringTable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadSpriteTypes
/*
This method loads all the sprite types found in the provided sprite type list file
into the game state manager, including their images.
*/
bool PoseurSpriteTypesImporter::loadSpriteTypes(Game *game, wstring spriteTypesListFileName)
{
int slashIndex = spriteTypesListFileName.rfind('/');
dir = string(spriteTypesListFileName.begin(), spriteTypesListFileName.end()).substr(0, slashIndex+1);
const char *spriteTypesListFile = newCharArrayFromWstring(spriteTypesListFileName);
bool success = loadSpriteTypesListInfo(spriteTypesListFile);
if (!success) return false;
for (unsigned int i = 0; i < spriteTypes.size(); i++)
{
success = loadSpriteTypeInfo(spriteTypes[i]);
if (!success) return false;
}
TextureManager *tm = game->getGraphics()->getWorldTextureManager();
WStringTable *wStringTable = tm->getWStringTable();
// NOW LET'S USE ALL THE INFO WE'VE LOADED
// LET'S START BY LOADING THE TEXTURES INTO THE WORLD TEXTURE MANAGER
for (unsigned int i = 0; i < spriteTypes.size(); i++)
{
string spriteType = spriteTypes[i];
unsigned int offset = wStringTable->getNumWStringsInTable();
map<int, string> images = spriteTypesImages[spriteType];
for (int j = 0; j < images.size(); j++)
{
string imageToLoad = images[j];
wstring wImageToLoad(imageToLoad.begin(), imageToLoad.end());
tm->loadTexture(wImageToLoad);
}
AnimatedSpriteType *ast = new AnimatedSpriteType();
unsigned int spriteTypeId = game->getGSM()->getSpriteManager()->addSpriteType(ast);
ast->setSpriteTypeID(spriteTypeId);
Dimensions dim = spriteTypesDimensions[spriteType];
ast->setTextureSize(dim.width, dim.height);
map<string, vector<Pose>> animations = spriteTypesAnimationsLists[spriteType];
map<string, vector<Pose>>::iterator it = animations.begin();
while (it != animations.end())
{
string key = it->first;
wstring wKey(key.begin(), key.end());
ast->addAnimationSequence(wKey);
vector<Pose> poseList = it->second;
vector<Pose>::iterator poseIt = poseList.begin();
while (poseIt != poseList.end())
{
Pose pose = *poseIt;
ast->addAnimationFrame(wKey, pose.imageId + offset - 1, pose.duration);
poseIt++;
}
it++;
}
}
return true;
}
示例2: 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;
//.........这里部分代码省略.........
示例3: 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;
//.........这里部分代码省略.........