本文整理汇总了C++中TMXMapInfo::setStaggerAxis方法的典型用法代码示例。如果您正苦于以下问题:C++ TMXMapInfo::setStaggerAxis方法的具体用法?C++ TMXMapInfo::setStaggerAxis怎么用?C++ TMXMapInfo::setStaggerAxis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TMXMapInfo
的用法示例。
在下文中一共展示了TMXMapInfo::setStaggerAxis方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: startElement
// the XML parser calls here with all the elements
void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
{
CC_UNUSED_PARAM(ctx);
TMXMapInfo *tmxMapInfo = this;
std::string elementName = name;
ValueMap attributeDict;
if (atts && atts[0])
{
for (int i = 0; atts[i]; i += 2)
{
std::string key = atts[i];
std::string value = atts[i+1];
attributeDict.insert(std::make_pair(key, Value(value)));
}
}
if (elementName == "map")
{
std::string version = attributeDict["version"].asString();
if ( version != "1.0")
{
CCLOG("cocos2d: TMXFormat: Unsupported TMX version: %s", version.c_str());
}
std::string orientationStr = attributeDict["orientation"].asString();
if (orientationStr == "orthogonal") {
tmxMapInfo->setOrientation(TMXOrientationOrtho);
}
else if (orientationStr == "isometric") {
tmxMapInfo->setOrientation(TMXOrientationIso);
}
else if (orientationStr == "hexagonal") {
tmxMapInfo->setOrientation(TMXOrientationHex);
}
else if (orientationStr == "staggered") {
tmxMapInfo->setOrientation(TMXOrientationStaggered);
}
else {
CCLOG("cocos2d: TMXFomat: Unsupported orientation: %d", tmxMapInfo->getOrientation());
}
std::string staggerAxisStr = attributeDict["staggeraxis"].asString();
if (staggerAxisStr == "x") {
tmxMapInfo->setStaggerAxis(TMXStaggerAxis_X);
}
else if (staggerAxisStr == "y") {
tmxMapInfo->setStaggerAxis(TMXStaggerAxis_Y);
}
std::string staggerIndex = attributeDict["staggerindex"].asString();
if (staggerIndex == "odd") {
tmxMapInfo->setStaggerIndex(TMXStaggerIndex_Odd);
}
else if (staggerIndex == "even") {
tmxMapInfo->setStaggerIndex(TMXStaggerIndex_Even);
}
float hexSideLength = attributeDict["hexsidelength"].asFloat();
tmxMapInfo->setHexSideLength(hexSideLength);
Size s;
s.width = attributeDict["width"].asFloat();
s.height = attributeDict["height"].asFloat();
tmxMapInfo->setMapSize(s);
s.width = attributeDict["tilewidth"].asFloat();
s.height = attributeDict["tileheight"].asFloat();
tmxMapInfo->setTileSize(s);
// The parent element is now "map"
tmxMapInfo->setParentElement(TMXPropertyMap);
}
else if (elementName == "tileset")
{
// If this is an external tileset then start parsing that
std::string externalTilesetFilename = attributeDict["source"].asString();
if (externalTilesetFilename != "")
{
_externalTilesetFilename = externalTilesetFilename;
// Tileset file will be relative to the map file. So we need to convert it to an absolute path
if (_TMXFileName.find_last_of("/") != string::npos)
{
string dir = _TMXFileName.substr(0, _TMXFileName.find_last_of("/") + 1);
externalTilesetFilename = dir + externalTilesetFilename;
}
else
{
externalTilesetFilename = _resources + "/" + externalTilesetFilename;
}
externalTilesetFilename = FileUtils::getInstance()->fullPathForFilename(externalTilesetFilename);
_currentFirstGID = attributeDict["firstgid"].asInt();
if (_currentFirstGID < 0)
{
_currentFirstGID = 0;
}
_recordFirstGID = false;
//.........这里部分代码省略.........