-2

嗨,这是我第一次尝试用 python 编写视频游戏。所以我找到了一个教程视频,它与我的(mac)在同一操作系统上运行,但是当我在视频中编写设置时:

#Setup
import turtle

wn=turtle.Screen
wn.title("Pong")
wn.bgcolor("black")
wn.setup(width=800, heigth=600)
wn.tracer(0)

#Main game loop
while True:
    wn.update()

出现了这个错误:

AttributeError: 'function' object has no attribute 'title'

有谁知道这意味着什么以及如何解决它?顺便说一句,我正在运行 python 3.10.0

4

2 回答 2

-1

t1

试试这个

#Setup
import turtle

wn=turtle.Screen()#call the Screen like: Screen()
wn.title("Pong")
wn.bgcolor("black")
wn.setup(width=800, height=600)
wn.tracer(0)

#Main game loop
while True:
    turtle.update()

有效果吗??

于 2021-11-02T14:58:59.030 回答
-1

t1 没用 试试这个

#Setup
import turtle

wn=turtle.Screen()#call the Screen like: Screen()
wn.title("Pong")
wn.bgcolor("black")
wn.setup(width=800, height=600)
wn.tracer(0)

#Main game loop
turtle.done()

尝试使用完成而不是更新
可以吗?

于 2021-11-02T15:33:33.737 回答