python-sfml入门。这段代码
import sfml
window = sfml.RenderWindow(sfml.VideoMode(640, 480), "FooBar")
try:
texture = sfml.Texture.from_file("brick_002.jpg")
sprite = sfml.Sprite(texture)
font = sfml.Font.from_file("arial.ttf")
text = sfml.Text("Math Rocks!")
except IOError:
exit(1)
while window.is_open:
for event in window.events:
if type(event) is sfml.CloseEvent:
window.close()
window.clear()
window.draw(sprite)
window.draw(text)
window.display()
并犯了这个错误:
Traceback (most recent call last):
File "sfml.py", line 1, in <module>
import sfml
File "/home/montreal/projects/foo/sfml/sfml.py", line 4, in <module>
window = sfml.RenderWindow(sfml.VideoMode(640, 480), "FooBar")
AttributeError: 'module' object has no attribute 'RenderWindow'
但是在翻译中,每个人的工作都很好(我可以创建窗口,添加纹理并关闭它)。什么可能是错的?