from livewires import games, color
#Creating and validating the pygame screen.
scrwidth = 640
scrheight = 480
fps = 50
myscr = games.Screen(scrwidth, scrheight)
#Loading an image into memory to create an image object
wall_image = games.load_image("wall.jpg", transparent = False)
myscr.set_background (wall_image)
#Printing Arbitary Score
texty = games.Text(value = "Score: 2048321",
size = 70,
color = color.black,
x = 400,
y = 30)
myscr.add(texty)
myscr.mainloop()
由于某些原因,我无法在指定的位置打印分数字符串。在
当我在没有给给定对象赋值变量的情况下做同样的事情时,我能够成功地做到这一点,但现在我没有把它赋给一个变量。在
如有任何意见,我们将不胜感激。提前谢谢。在
编辑:按要求,工作代码。在
^{pr2}$我们到了!工作代码:
from livewires import games, color
#Creating and validating the pygame screen.
scrwidth = 640
scrheight = 480
fpsy = 50
games.init(screen_width = scrwidth, screen_height =scrheight, fps = fpsy)
myscr = games.screen
#Loading an image into memory to create an image object
wall_image = games.load_image("wall.jpg", transparent = False)
myscr.background = wall_image
#Printing Arbitary Score
texty = games.Text(value = "Score: 2048321",
size = 70,
color = color.black,
x = 400,
y = 30)
myscr.add(texty)
myscr.mainloop()
我想我知道发生了什么,如果我没有错的话,你可以假设
在游戏.init(屏幕宽度=640,屏幕高度=480, fps=50)
是同一件事
但情况可能并非如此,arguments int Screen不按特定顺序查找name=value对,因此仅值对可能不起作用。但是你可以这么做
^{pr2}$我猜既然你的尺寸没有设置好,而且文本中的x,y是绝对变量,那么你的文本可能会一团糟
相关问题 更多 >
编程相关推荐