我搜索一个可以使用python3以tmx格式导出/保存map
的lib。我找到了:
最后,没有保存功能。加载地图后,您可以自行决定是否保存对地图的更改。我已经使用了pickle模块,效果很好。
Saving is equally easy:
>>> map.save('saved.tmx')
>>> map_as_string = map.dump()
但是pip安装失败(python3):
pip install tmxlib
Downloading/unpacking tmxlib
Downloading tmxlib-0.2.1.tar.gz
Running setup.py (path:/home/bux/.virtualenvs/testsynergine2/build/tmxlib/setup.py) egg_info for package tmxlib
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/home/bux/.virtualenvs/testsynergine2/build/tmxlib/setup.py", line 59, in <module>
import tmxlib
File "/home/bux/.virtualenvs/testsynergine2/build/tmxlib/tmxlib/__init__.py", line 9, in <module>
from tmxlib.map import Map
File "/home/bux/.virtualenvs/testsynergine2/build/tmxlib/tmxlib/map.py", line 5, in <module>
from tmxlib import helpers, fileio, tileset, layer
File "/home/bux/.virtualenvs/testsynergine2/build/tmxlib/tmxlib/tileset.py", line 8, in <module>
from tmxlib import helpers, fileio, tile, image, terrain
File "/home/bux/.virtualenvs/testsynergine2/build/tmxlib/tmxlib/image.py", line 28, in <module>
preferred_image_class = image_classes[0]
IndexError: list index out of range
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info/tmxlib.egg-info
writing top-level names to pip-egg-info/tmxlib.egg-info/top_level.txt
writing requirements to pip-egg-info/tmxlib.egg-info/requires.txt
writing dependency_links to pip-egg-info/tmxlib.egg-info/dependency_links.txt
writing pip-egg-info/tmxlib.egg-info/PKG-INFO
writing manifest file 'pip-egg-info/tmxlib.egg-info/SOURCES.txt'
warning: manifest_maker: standard file '-c' not found
reading manifest file 'pip-egg-info/tmxlib.egg-info/SOURCES.txt'
writing manifest file 'pip-egg-info/tmxlib.egg-info/SOURCES.txt'
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/home/bux/.virtualenvs/testsynergine2/build/tmxlib/setup.py", line 59, in <module>
import tmxlib
File "/home/bux/.virtualenvs/testsynergine2/build/tmxlib/tmxlib/__init__.py", line 9, in <module>
from tmxlib.map import Map
File "/home/bux/.virtualenvs/testsynergine2/build/tmxlib/tmxlib/map.py", line 5, in <module>
from tmxlib import helpers, fileio, tileset, layer
File "/home/bux/.virtualenvs/testsynergine2/build/tmxlib/tmxlib/tileset.py", line 8, in <module>
from tmxlib import helpers, fileio, tile, image, terrain
File "/home/bux/.virtualenvs/testsynergine2/build/tmxlib/tmxlib/image.py", line 28, in <module>
preferred_image_class = image_classes[0]
IndexError: list index out of range
----------------------------------------
Cleaning up...
你知道tmx库可以做到这一点,还是安装tmxlib的方法?
答案 0 :(得分:0)
我已经使用pip成功安装了python3。如果pip install不适合你,那么:
通过发送命令
通过终端运行此脚本python setup.py install
它会有希望地发挥作用。另外我觉得图书馆很好..可能你的pip版本中有一个错误。
答案 1 :(得分:0)
可用其他tmx lib:http://pythonhosted.org/tmx/(https://pypi.python.org/pypi/tmx。这可以加载和保存。