错误:
Error Traceback (most recent call last):
File "/home/enrique/Dropbox/Public/pygametut3.py", line 41, in <module>
pix = MovingPixel(width/2, height/2)
TypeError: this constructor takes no arguments
守则:
#Creat a moving pixel
pix = MovingPixel(width/2, height/2)
while running:
pix.move()
if pix.x <= 0 or pix.x >= width or pix.y <= 0 or pix.y >= height:
print "Crash"
running = False
答案 0 :(得分:1)
因为MovingPixel
需要在没有参数的情况下实例化:
pix = MovingPixel()
答案 1 :(得分:0)
您创建了MovingPixel对象,将两个参数传递给构造函数,它不需要参数。您是否忘记导入正确的模块?
如果您指的是这样的内容:http://lorenzod8n.wordpress.com/tag/python/您应该知道MovingPixel不是内置类,如果您想使用它,则必须下载模块/源。