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()
出於某種原因,我無法在分配給它的位置打印分數字符串。調試Python pygame程序
當我做同樣的事情沒有分配變量給定的對象,我能夠成功地做到這一點,但現在我不是我已經把它分配給一個變量。
任何輸入,將不勝感激。提前致謝。
編輯:根據要求,工作代碼。
from livewires import games, color
games.init(screen_width = 640, screen_height = 480, fps = 50)
wall_image = games.load_image("wall.jpg", transparent = False)
games.screen.background = wall_image
score = games.Text(value = 1756521,
size = 60,
color = color.black,
x = 550,
y = 30)
games.screen.add(score)
games.screen.mainloop()
在這裏,我們是!工作代碼:
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()
你能提供的代碼版本你談論,你「在沒有給給定對象分配變量的情況下做同樣的事情」,它的工作原理? –
你可以在分配變量之前發佈初始代碼嗎? –
當然,在沒有的代碼下發布。請稍等。 – Louis93