调试通过 livewires 运行的 Python pygame

发布于 2024-11-16 22:48:34 字数 522 浏览 3 评论 0原文

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()

Python seems to completely ignore one of my objects - the games.Text object. Can't seem to understand why, syntax seems correct. Here's the code.

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()

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冰之心 2024-11-23 22:48:34

你的问题似乎是在一些地方拼写错误“颜色”(这个包来自英国),忘记

from livewires import colour

并且没有注意到错误消息的某种组合:

NameError: name 'color' is not defined

至少我认为这是你的问题,因为在这些更改之后它运行得很好对我来说,在右上角显示“分数”文本。

Your problem seems to be some combination of misspelling "colour" in a few places (this package is from the UK), forgetting

from livewires import colour

and failing to notice an error message:

NameError: name 'color' is not defined

At least I assume that's your problem, because after those changes it runs just fine for me, displaying the "score" text in the top right.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文