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


Python Layer.width方法代码示例

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


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

示例1: startElement

# 需要导入模块: from layer import Layer [as 别名]
# 或者: from layer.Layer import width [as 别名]
	def startElement(self, name, attrs):
		if name == 'map':
			# We can get some basic info about the map from this tag
			if 'width' in attrs.getNames():
				# Be careful here, attrs.getValue always return a
				# string, so always convert afterwards
				self.map.size[0] = int(attrs.getValue('width'))
			
			if 'height' in attrs.getNames():
				self.map.size[1] = int(attrs.getValue('height'))
			
			# remember that we are in this tag
			self.inMap = True
		
		# Tileset tag
		# Add a new tileset to the map with all the options
		if name == 'tileset' and self.inMap == True:
			# Make a new blank tileset.
			tileset = Tileset()
			
			# Attach the map to the tileset
			tileset.map = self.map
			
			# Fill it with some of the new info in this tag
			if 'tilewidth' in attrs.getNames():
				tileset.tileSize[0] = int(attrs.getValue('tilewidth'))
			if 'tileheight' in attrs.getNames():
				tileset.tileSize[1] = int(attrs.getValue('tileheight'))
			if 'name' in attrs.getNames():
				tileset.name = attrs.getValue('name')
				
			# K, add this tileset to the loaded map
			self.map.tilesets.append(tileset)
			
			# We can add things from nested tags into it later.
			
			self.inTileset = True
			
		# Image Tag
		# We should add this image to the current tileset
		if name == 'image' and self.inTileset:
			# Find the location of the image and load it
			if 'source' in attrs.getNames():
				self.map.tilesets[-1].load(attrs.getValue('source'), self.map.tilesets[-1].tileSize)
			
			# K, done... assuming that image loaded.
			
		# Layer Tag
		if name == 'layer' and self.inMap:
			# Make a new layer
			layer = Layer()
			
			# Attach layer to map
			layer.map = self.map
			
			# Get the name of the layer
			if 'name' in attrs.getNames():
				layer.name = attrs.getValue('name')
			
			# Width and Height
			if 'width' in attrs.getNames():
				layer.width = int(attrs.getValue('width'))
			if 'height' in attrs.getNames():
				layer.height = int(attrs.getValue('height'))
			
			# Add the new layer to the map
			self.map.layers.append(layer)
			
			# We're inside the layer tag now
			self.inLayer = True
		
		# Properties
		if name == 'properties' and self.inLayer:
			self.inProperties = True
		
		if name == 'property' and self.inProperties and self.inLayer:
			# Add this property to the current layer
			if 'name' in attrs.getNames():
				if attrs.getValue('name') == 'Solid':
					if 'value' in attrs.getNames():
						if attrs.getValue('value') == '1':
							self.map.layers[-1].solid = True
		
		# Data Tag
		if name == 'data' and self.inLayer:
			# Find out how the data is encoded
			if 'encoding' in attrs.getNames():
				self.dataEncoding = attrs.getValue('encoding')
			
			# Flush the buffer
			self.dataBuffer = ''
			
			# Inside data, now we can load the layer data
			self.inData = True	
开发者ID:bombpersons,项目名称:RPGlibs,代码行数:96,代码来源:map.py


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