本文整理汇总了Python中map.Map.setHexSideLength方法的典型用法代码示例。如果您正苦于以下问题:Python Map.setHexSideLength方法的具体用法?Python Map.setHexSideLength怎么用?Python Map.setHexSideLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类map.Map
的用法示例。
在下文中一共展示了Map.setHexSideLength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: toMap
# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import setHexSideLength [as 别名]
def toMap(self, variant, mapDir):
self.mGidMapper.clear()
self.mMapDir = mapDir
variantMap = variant
orientationString = variantMap.get("orientation", '')
orientation = orientationFromString(orientationString)
if (orientation == Map.Orientation.Unknown):
self.mError = self.tr("Unsupported map orientation: \"%s\""%orientationString)
return None
staggerAxisString = variantMap.get("staggeraxis", '')
staggerAxis = staggerAxisFromString(staggerAxisString)
staggerIndexString = variantMap.get("staggerindex", '')
staggerIndex = staggerIndexFromString(staggerIndexString)
renderOrderString = variantMap.get("renderorder", '')
renderOrder = renderOrderFromString(renderOrderString)
nextObjectId = variantMap.get("nextobjectid", 0)
map = Map(orientation,
variantMap.get("width",0),
variantMap.get("height",0),
variantMap.get("tilewidth",0),
variantMap.get("tileheight",0))
map.setHexSideLength(variantMap.get("hexsidelength", 0))
map.setStaggerAxis(staggerAxis)
map.setStaggerIndex(staggerIndex)
map.setRenderOrder(renderOrder)
if (nextObjectId):
map.setNextObjectId(nextObjectId)
self.mMap = map
map.setProperties(self.toProperties(variantMap.get("properties", {})))
bgColor = variantMap.get("backgroundcolor", '')
if (bgColor!='' and QColor.isValidColor(bgColor)):
map.setBackgroundColor(QColor(bgColor))
for tilesetVariant in variantMap.get("tilesets", []):
tileset = self.__toTileset(tilesetVariant)
if not tileset:
return None
map.addTileset(tileset)
for layerVariant in variantMap.get("layers", []):
layer = self.toLayer(layerVariant)
if not layer:
return None
map.addLayer(layer)
return map
示例2: MapReaderPrivate
# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import setHexSideLength [as 别名]
class MapReaderPrivate():
def tr(self, sourceText, disambiguation = '', n = -1):
return QCoreApplication.translate('MapReader', sourceText, disambiguation, n)
def trUtf8(self, sourceText, disambiguation = '', n = -1):
return QCoreApplication.translate('MapReader', sourceText, disambiguation, n)
def __init__(self, mapReader):
self.p = mapReader
self.mMap = None
self.mError = QString('')
self.mReadingExternalTileset = False
self.xml = QXmlStreamReader()
self.mGidMapper = GidMapper()
def readMap(self, device, path):
self.mError = QString('')
self.mPath = path
map = None
self.xml.setDevice(device)
if (self.xml.readNextStartElement() and self.xml.name() == "map"):
map = self.__readMap()
else:
self.xml.raiseError(self.tr("Not a map file."))
self.mGidMapper.clear()
return map
def readTileset(self, device, path):
self.mError = ''
self.mPath = path
tileset = None
self.mReadingExternalTileset = True
self.xml.setDevice(device)
if (self.xml.readNextStartElement() and self.xml.name() == "tileset"):
tileset = self.__readTileset()
else:
self.xml.raiseError(self.tr("Not a tileset file."))
self.mReadingExternalTileset = False
return tileset
def openFile(self, file):
if (not file.exists()):
self.mError = self.tr("File not found: %s"%file.fileName())
return False
elif (not file.open(QFile.ReadOnly | QFile.Text)):
self.mError = self.tr("Unable to read file: %s"%file.fileName())
return False
return True
def errorString(self):
if self.mError != '':
return self.mError
else:
return self.tr("%d\n\nLine %d, column %s"%(self.xml.lineNumber(), self.xml.columnNumber(), self.xml.errorString()))
def __readUnknownElement(self):
qDebug("Unknown element (fixme): "+self.xml.name()+" at line "+self.xml.lineNumber()+", column "+self.xml.columnNumber())
self.xml.skipCurrentElement()
def __readMap(self):
atts = self.xml.attributes()
mapWidth = Int(atts.value("width"))
mapHeight = Int(atts.value("height"))
tileWidth = Int(atts.value("tilewidth"))
tileHeight = Int(atts.value("tileheight"))
hexSideLength = Int(atts.value("hexsidelength"))
orientationString = atts.value("orientation")
orientation = orientationFromString(orientationString)
if (orientation == Map.Orientation.Unknown):
self.xml.raiseError(self.tr("Unsupported map orientation: \"%s\""%orientationString))
staggerAxisString = atts.value("staggeraxis")
staggerAxis = staggerAxisFromString(staggerAxisString)
staggerIndexString = atts.value("staggerindex")
staggerIndex = staggerIndexFromString(staggerIndexString)
renderOrderString = atts.value("renderorder")
renderOrder = renderOrderFromString(renderOrderString)
nextObjectId = Int(atts.value("nextobjectid"))
self.mMap = Map(orientation, mapWidth, mapHeight, tileWidth, tileHeight)
self.mMap.setHexSideLength(hexSideLength)
self.mMap.setStaggerAxis(staggerAxis)
self.mMap.setStaggerIndex(staggerIndex)
self.mMap.setRenderOrder(renderOrder)
if (nextObjectId):
self.mMap.setNextObjectId(nextObjectId)
bgColorString = atts.value("backgroundcolor")
if len(bgColorString)>0:
self.mMap.setBackgroundColor(QColor(bgColorString))
while (self.xml.readNextStartElement()):
if (self.xml.name() == "properties"):
self.mMap.mergeProperties(self.__readProperties())
elif (self.xml.name() == "tileset"):
self.mMap.addTileset(self.__readTileset())
elif (self.xml.name() == "layer"):
self.mMap.addLayer(self.__readLayer())
elif (self.xml.name() == "objectgroup"):
self.mMap.addLayer(self.__readObjectGroup())
#.........这里部分代码省略.........