本文整理汇总了C++中TMXLayer::setTileGID方法的典型用法代码示例。如果您正苦于以下问题:C++ TMXLayer::setTileGID方法的具体用法?C++ TMXLayer::setTileGID怎么用?C++ TMXLayer::setTileGID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TMXLayer
的用法示例。
在下文中一共展示了TMXLayer::setTileGID方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bulletBoom
void Bullet::bulletBoom()
{
Rect rect = getBoundingBox();
Size mapSize = mTileMapInfo->getTileMap()->getContentSize();
if (rect.getMinX() < 0 || rect.getMaxX() >= mapSize.width || rect.getMinY() < 0
|| rect.getMaxY() >= mapSize.height)
return;
TMXLayer* tmxLayer = mTileMapInfo->getTileMap()->getLayer("layer_0");
Size tileSize = tmxLayer->getMapTileSize();
float MinY = mapSize.height - rect.getMinY();
float MaxY = mapSize.height - rect.getMaxY();
Point pt = Point((int) rect.getMinX() / tileSize.width, (int) (MinY / tileSize.height));
if (gidToTileType[tmxLayer->getTileGIDAt(pt)] == tileWall)
tmxLayer->setTileGID(gidToTileType[tileNone], pt);
pt = Point((int) rect.getMinX() / tileSize.width, (int) (MaxY / tileSize.height));
if (gidToTileType[tmxLayer->getTileGIDAt(pt)] == tileWall)
tmxLayer->setTileGID(gidToTileType[tileNone], pt);
pt = Point((int) rect.getMaxX() / tileSize.width, (int) (MinY / tileSize.height));
if (gidToTileType[tmxLayer->getTileGIDAt(pt)] == tileWall)
tmxLayer->setTileGID(gidToTileType[tileNone], pt);
pt = Point((int) rect.getMaxX() / tileSize.width, (int) (MaxY / tileSize.height));
if (gidToTileType[tmxLayer->getTileGIDAt(pt)] == tileWall)
tmxLayer->setTileGID(gidToTileType[tileNone], pt);
}
示例2: onTouchBegan
bool HelloWorld::onTouchBegan(Touch* touch, Event* event)
{
auto m_tBeginPos = Point(touch->getLocation().x,touch->getLocation().y);
auto map = static_cast<TMXTiledMap*>( getChildByTag(1));
Point mapp = map->getPosition();
Point aimmapindex = convertto2d(m_tBeginPos.x - mapp.x,m_tBeginPos.y - mapp.y);
if(aimmapindex.x < 0 || aimmapindex.y < 0 || aimmapindex.x >= map->getMapSize().width || aimmapindex.y >= map->getMapSize().height)
{
return false;
}
TMXLayer* layer = map->layerNamed("grass");
layer->setTileGID(4,aimmapindex);
return true;
}
示例3: addChild
TMXResizeTest::TMXResizeTest()
{
auto map = TMXTiledMap::create("TileMaps/orthogonal-test5.tmx");
addChild(map, 0, kTagTileMap);
Size CC_UNUSED s = map->getContentSize();
CCLOG("ContentSize: %f, %f", s.width,s.height);
TMXLayer* layer;
layer = map->getLayer("Layer 0");
auto ls = layer->getLayerSize();
for (unsigned int y = 0; y < ls.height; y++)
{
for (unsigned int x = 0; x < ls.width; x++)
{
layer->setTileGID(1, Vec2( x, y ) );
}
}
}