当前位置: 首页>>代码示例>>Python>>正文


Python Map.setRenderOrder方法代码示例

本文整理汇总了Python中map.Map.setRenderOrder方法的典型用法代码示例。如果您正苦于以下问题:Python Map.setRenderOrder方法的具体用法?Python Map.setRenderOrder怎么用?Python Map.setRenderOrder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在map.Map的用法示例。


在下文中一共展示了Map.setRenderOrder方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: copySelection

# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import setRenderOrder [as 别名]
    def copySelection(self, mapDocument):
        currentLayer = mapDocument.currentLayer()
        if (not currentLayer):
            return
        map = mapDocument.map()
        selectedArea = mapDocument.selectedArea()
        selectedObjects = mapDocument.selectedObjects()
        tileLayer = currentLayer
        copyLayer = None
        if (not selectedArea.isEmpty() and type(tileLayer)==TileLayer):
            # Copy the selected part of the layer
            copyLayer = tileLayer.copy(selectedArea.translated(-tileLayer.x(), -tileLayer.y()))
        elif (not selectedObjects.isEmpty()):
            # Create a new object group with clones of the selected objects
            objectGroup = ObjectGroup()
            for mapObject in selectedObjects:
                objectGroup.addObject(mapObject.clone())
            copyLayer = objectGroup
        else:
            return

        # Create a temporary map to write to the clipboard
        copyMap = Map(map.orientation(),
                    copyLayer.width(), copyLayer.height(),
                    map.tileWidth(), map.tileHeight())
        copyMap.setRenderOrder(map.renderOrder())
        # Resolve the set of tilesets used by this layer
        for tileset in copyLayer.usedTilesets():
            copyMap.addTileset(tileset)
        copyMap.addLayer(copyLayer)
        self.setMap(copyMap)
开发者ID:theall,项目名称:Python-Tiled,代码行数:33,代码来源:clipboardmanager.py

示例2: toMap

# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import setRenderOrder [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
开发者ID:theall,项目名称:Python-Tiled,代码行数:50,代码来源:varianttomapconverter.py

示例3: stampFromContext

# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import setRenderOrder [as 别名]
def stampFromContext(selectedTool):
    stamp = TileStamp()
    stampBrush = dynamic_cast(selectedTool, StampBrush)
    if stampBrush:
        # take the stamp from the stamp brush
        stamp = stampBrush.stamp()
    else:
        fillTool = dynamic_cast(selectedTool, BucketFillTool)
        if fillTool:
            # take the stamp from the fill tool
            stamp = fillTool.stamp()
        else:
            mapDocument = DocumentManager.instance().currentDocument()
            if mapDocument:
                # try making a stamp from the current tile selection
                tileLayer = dynamic_cast(mapDocument.currentLayer(), TileLayer)
                if (not tileLayer):
                    return stamp
                selection = mapDocument.selectedArea()
                if (selection.isEmpty()):
                    return stamp
                selection.translate(-tileLayer.position())
                copy = tileLayer.copy(selection)
                if (copy.size().isEmpty()):
                    return stamp
                map = mapDocument.map()
                copyMap = Map(map.orientation(),
                                       copy.width(), copy.height(),
                                       map.tileWidth(), map.tileHeight())
                # Add tileset references to map
                for tileset in copy.usedTilesets():
                    copyMap.addTileset(tileset)
                copyMap.setRenderOrder(map.renderOrder())
                copyMap.addLayer(copy.take())
                stamp.addVariation(copyMap)
    
    return stamp
开发者ID:theall,项目名称:Python-Tiled,代码行数:39,代码来源:tilestampmanager.py

示例4: MapReaderPrivate

# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import setRenderOrder [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())
#.........这里部分代码省略.........
开发者ID:theall,项目名称:Python-Tiled,代码行数:103,代码来源:mapreader.py


注:本文中的map.Map.setRenderOrder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。