[英]I made a very simple Pygame Zero game, but my Actor image and the screen.clear() is not working. Can you help me fix this?
這是非常糟糕的游戲示例的完整代碼。
import pgzrun
from random import randint
from pgzero.builtins import Actor, animate, keyboard
apple = Actor('apple')
def draw():
screen.clear()
apple.draw()
def place_apple():
apple.x = randint(10, 800)
apple.y = randint(10, 600)
def on_mouse_down(pos):
if apple.collidepont(pos):
print("Good shot!")
place_apple()
else:
print("You missed!")
quit()
place_apple()
pgzrun.go()
screen.clear() 不起作用,並且 apple = actor("apple") 也不起作用。 我不知道為什么。 請幫我!
嘗試這個:
from pgzero.actor import Actor
from pgzero.keyboard import keyboard
不確定是否有幫助。
您使用的是 mu 編輯器還是 pycharm?
你有正確路徑中的蘋果圖像嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.