【发布时间】:2011-06-22 16:15:20
【问题描述】:
Python 似乎完全忽略了我的一个对象 - games.Text 对象。似乎无法理解为什么,语法似乎正确。这是代码。
from livewires import games
#Creating and validating the pygame screen.
myscreen = games.Screen ()
#Loading an image into memory to create an image object
wall_image = games.load_image("wall.jpg", transparent = False)
myscreen.set_background(wall_image)
#Printing Arbitary Score
games.Text(screen = myscreen, x = 500, y = 30,
text = "Score: 1756521",
size = 50, color = color.black)
myscreen.mainloop()
【问题讨论】:
-
忽略到底是什么意思?你想让程序做什么?我不熟悉 livewires,但 games.Text 是对象还是方法?如果您正在初始化一个对象,您可能希望将其存储在一个变量中。
-
对不起,set_background to wall image 部分设置了我选择的 jpg 的背景图像(此处为 wall.jpg),而 games.Text 部分应该将文本插入到 ( 500,30) 屏幕坐标。它应该打印 Score: 1756521, color = black。
-
当你说它“应该”插入文本时,你的意思是你在某些文档中读到它吗?
-
教科书。明白了,这是进口错误。不过还是谢谢。
标签: python debugging pygame livewires