本文整理汇总了C++中TMXLayer::getLayerSize方法的典型用法代码示例。如果您正苦于以下问题:C++ TMXLayer::getLayerSize方法的具体用法?C++ TMXLayer::getLayerSize怎么用?C++ TMXLayer::getLayerSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TMXLayer
的用法示例。
在下文中一共展示了TMXLayer::getLayerSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool SelectRoundLayer::init()
{
if (!Layer::init())
return false;
// background
std::string filePath = FileUtils::getInstance()->fullPathForFilename("selectRound.tmx");
TiledMapParser* tiledMapParser = TiledMapParser::create(filePath);
TMXLayer* layer = tiledMapParser->createLayer("backgroundLayer");
addChild(layer);
int max_passed_round = GameController::getInstance()->maxPassedRound();
Point pos;
// round buttons
MapGidToGamePos map;
tiledMapParser->getGidToGamePosMap("roundIconLayer", &map);
MapGidToGamePos::iterator it = map.begin();
for (; map.end() != it; ++it) {
int round = it->first - 1;
createRoundButton(round, GameController::getInstance()->isUnlock(round), it->second);
if (max_passed_round == round)
pos = it->second;
}
Size layer_size = layer->getLayerSize();
Size visibleSize = Director::getInstance()->getVisibleSize();
int height_offset = layer_size.height - visibleSize.height;
Vec2 visibleOrigin = Director::getInstance()->getVisibleOrigin();
setPosition(Vec2(visibleOrigin.x, visibleOrigin.y + height_offset));
setTouchEnabled(true);
return true;
}
示例2: _dealMap
void BattleLayer::_dealMap(){
Size visibleSize = Director::getInstance()->getVisibleSize();
_battleMapBackground = LayerColor::create(Color4B(0, 0, 0, 255), visibleSize.width, visibleSize.height);
_battleMapBackground->setPosition(0, 0);
this->addChild(_battleMapBackground, 0);
TMXTiledMap *tiledMap = TMXTiledMap::create("res/map/battle_map.tmx");
TMXLayer *backgroundLayer = tiledMap->getLayer("background");
TMXLayer *walkableLayer = tiledMap->getLayer("walkable");
walkableLayer->setAnchorPoint(Vec2(0.5, 0.5));
walkableLayer->setPosition(visibleSize.width / 2, visibleSize.height / 2 + 90);
_battleMapBackground->addChild(walkableLayer, 1);
backgroundLayer->setAnchorPoint(Vec2(0.5, 0.5));
backgroundLayer->setPosition(visibleSize.width / 2, visibleSize.height / 2 + 90);
_battleMapBackground->addChild(backgroundLayer, 1);
Size mapSize = walkableLayer->getLayerSize();
_battleMapTileSize = Size(20, 30);
_battleTileSize = walkableLayer->getMapTileSize();
_battleMapSize = Size(20 * _battleTileSize.width, 30 * _battleTileSize.height);
_battleMap = LayerColor::create(Color4B(255, 255, 255, 150), _battleMapSize.width, _battleMapSize.height);
_battleMap->ignoreAnchorPointForPosition(false);
_battleMap->setAnchorPoint(Vec2(0.5, 0.5));
_battleMap->setPosition(visibleSize.width / 2, visibleSize.height / 2 + 90);
_battleMapBackground->addChild(_battleMap, 5);
}
示例3: _makeAStarData
void BattleLayer::_makeAStarData(){
TMXTiledMap *tiledMap = TMXTiledMap::create("res/map/battle_map.tmx");
TMXLayer *walkableLayer = tiledMap->getLayer("walkable");
Size mapSize = walkableLayer->getLayerSize();
// CCLOG("MapSize: (%f, %f)", mapSize.width, mapSize.height);
AStarDataNode astarDataVec[20][30];
for (int column = 0; column < _battleMapTileSize.width; ++column){
for (int row = 0; row < _battleMapTileSize.height; ++row){
Vec2 tileCoord = Vec2(column + 5, mapSize.height - (row + 5) - 1);
int tileGID = walkableLayer->getTileGIDAt(tileCoord);
if (tileGID > 0){
Value value = tiledMap->getPropertiesForGID(tileGID);
ValueMap valueMap = value.asValueMap();
int walkable = valueMap["walkable"].asInt();
// CCLOG("Column: %d, Row: %d, Walkable: %d", column, row, walkable);
astarDataVec[column][row].column = column;
astarDataVec[column][row].row = row;
astarDataVec[column][row].walkable = (walkable == 0) ? false : true;
}
}
}
for (int column = 0; column < _battleMapTileSize.width; ++column){
std::vector<AStarDataNode> oneList;
std::vector<BattleElement *> oneBattleElementList;
for (int row = 0; row < _battleMapTileSize.height; ++row){
AStarDataNode astarDataNode = AStarDataNode(column, row, astarDataVec[column][row].walkable);
oneList.push_back(astarDataNode);
oneBattleElementList.push_back(nullptr);
}
astarData.push_back(oneList);
battleElements.push_back(oneBattleElementList);
}
// for (int row = 0; row < _battleMapTileSize.height; ++row){
// for (int column = 0; column < _battleMapTileSize.width; ++column){
// printf("%d", astarData[column][row].walkable);
// }
// printf("\n");
// }
}
示例4: 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 ) );
}
}
}