本文整理汇总了C++中TileNode::SetSurface方法的典型用法代码示例。如果您正苦于以下问题:C++ TileNode::SetSurface方法的具体用法?C++ TileNode::SetSurface怎么用?C++ TileNode::SetSurface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TileNode
的用法示例。
在下文中一共展示了TileNode::SetSurface方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FillInTiles
void Level::FillInTiles(Vector2 a_levelSize, std::vector<int>* a_idMap)
{
m_levelSize = a_levelSize;
m_tiles.reserve(a_levelSize.x / TILE_WIDTH * a_levelSize.y / TILE_HEIGHT);
for(int tileY = 0; tileY < a_levelSize.y / TILE_HEIGHT; tileY++)
{
for(int tileX = 0; tileX < a_levelSize.x / TILE_WIDTH; tileX++)
{
int index = tileX + tileY * (a_levelSize.x / TILE_WIDTH);
TileNode* t = new TileNode(tileY, tileX, (*a_idMap)[index]);
m_tiles.push_back(t);
t->SetSurface(t->m_iTileId);
}
}
}
示例2: ProcessTileMap
void TileManager::ProcessTileMap(std::string a_sFileName)
{
m_sCurrentLevel = a_sFileName;
int rows = m_pBaseSprite[a_sFileName]->GetHeight() / TILE_HEIGHT;
int columns = m_pBaseSprite[a_sFileName]->GetWidth() / TILE_WIDTH;
int idCounter = 0;
int id = 0;
int counter = 0;
for(int row = 0; row < rows; row++)
{
for(int col = 0; col < columns; col++)
{
Tmpl8::Surface* surface = new Tmpl8::Surface(TILE_WIDTH, TILE_HEIGHT);
m_pBaseSprite[a_sFileName]->CopyPartTo(surface, 0, 0, col * TILE_WIDTH, row * TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT);
if(row == 0 && col == 0)
{
TileNode* tileNode = new TileNode(row, col, 0);
m_pTiles[a_sFileName].push_back(tileNode);
m_pTileSurfaces[a_sFileName].push_back(new TileSurface(idCounter,surface));
tileNode->SetSurface(tileNode->m_iTileId);
counter++;
idCounter++;
continue;
}
bool isUnique = true;
for(std::vector<TileSurface*>::iterator iter = m_pTileSurfaces[a_sFileName].begin(); iter != m_pTileSurfaces[a_sFileName].end();)
{
if(!(*iter)->CompareSurfaces(surface))
{
isUnique = false;
id = (*iter)->m_iTileId;
iter = m_pTileSurfaces[a_sFileName].end();
}
else
{
iter++;
}
}
if(isUnique)
{
m_pTileSurfaces[a_sFileName].push_back(new TileSurface(idCounter,surface));
id = idCounter;
idCounter++;
}
else
{
delete surface;
}
TileNode* tileNode = new TileNode(row, col, id);
m_pTiles[a_sFileName].push_back(tileNode);
tileNode->SetSurface(tileNode->m_iTileId);
counter++;
}
}
FIBITMAP* bitmap = FreeImage_Allocate(512, 1024, 24);
int tilesInRow = 512 / TILE_WIDTH;
int rowCounter = 0;
int colCounter = 0;
for(std::vector<TileSurface*>::iterator iter = m_pTileSurfaces[a_sFileName].begin(); iter != m_pTileSurfaces[a_sFileName].end(); iter++)
{
Tmpl8::Pixel* buffer = (*iter)->m_pTileSurface->GetBuffer();
int pitch = (*iter)->m_pTileSurface->GetPitch();
for(int x = 0; x < TILE_WIDTH; x++)
{
for(int y = 0; y < TILE_HEIGHT; y++)
{
RGBQUAD color;
color.rgbRed = (buffer[x + y*pitch] & 0xFF0000) >> 16;
color.rgbGreen = (buffer[x + y*pitch] & 0x00FF00) >> 8;
color.rgbBlue = buffer[x + y*pitch] & 0x0000FF;
FreeImage_SetPixelColor(bitmap, colCounter*TILE_WIDTH + x, 1023 - rowCounter*TILE_HEIGHT - y, &color);
}
}
colCounter++;
if(colCounter >= tilesInRow)
{
colCounter = 0;
rowCounter++;
}
}
FreeImage_Save(FIF_PNG, bitmap, std::string("assets/tilesets/"+a_sFileName+"_tilemap.png").c_str(), 0);
std::string tileMap;
std::stringstream ss;
counter = 0;
for(int row = 0; row < rows; row++)
{
for(int col = 0; col < columns; col++)
{
TileNode* currentNode = m_pTiles[a_sFileName][counter];
counter++;
ss.str("");
//.........这里部分代码省略.........