AttributeError:'int'对象没有属性'hideturtle'???这意味着什么?

时间:2019-08-17 01:18:45

标签: python python-3.x turtle-graphics tkinter-canvas

我的代码有错误。我不知道该如何解决。 应该创建一个需要射击黄色方块的游戏。

有人可以帮助我吗? 这就是整个代码。

    import turtle as te
    from turtle import *
    import tkinter as tk
    from tkinter import *
    import time as t
    from time import *

    window = tk.Tk()
    canvas = tk.Canvas(window, width=750, height=500, bg="sky blue")
    canvas.pack()

    ground = canvas.create_rectangle(750, 100, 0, 0, fill="SpringGreen2")
    canvas.move(ground, 0, 400)

    ball = canvas.create_oval(0, 0, 10, 10, fill="deep pink")
    canvas.move(ball, 750/3.5 + 50, 0+17 + 190)

    shooter = canvas.create_rectangle(50, 50, 0, 0, fill="blue2")
    canvas.move(shooter, 750/3.5, 0+17 + 200)

    castle = canvas.create_rectangle(750/3.5, 500/1.5, 0, 0, fill="gray60")
    canvas.move(castle, 0, 400-500/1.5)

    power = canvas.create_rectangle(10, 10, 0, 0, fill="gray60")
    canvas.move(power, 400, 40)

    Bird = canvas.create_rectangle(60, 30, 0, 0, fill="gold")
    canvas.move(Bird, 650, 50)

    Birda = canvas.create_rectangle(60, 30, 0, 0, fill="gold")
    canvas.move(Birda, 650, 50)

    Birdb = canvas.create_rectangle(60, 30, 0, 0, fill="gold")
    canvas.move(Birdb, 650, 50)

    Birdc = canvas.create_rectangle(60, 30, 0, 0, fill="gold")
    canvas.move(Birdc, 650, 50)

    Lives = 3
    def part_one():
        Bird.hideturtle()
        Birda.hideturtle
        Birdb.hideturtle()
        Birdc.hideturtle()

创建相同的错误都需要

1 个答案:

答案 0 :(得分:0)

BirdBirdaBirdcCanvas的项目ID(int),可让您要求canvas修改图形它们标识的元素(在这种情况下为矩形)。它们都不是hideturtle()方法,因为它们不是乌龟实例。您尚未创建任何乌龟实例。到目前为止,在您的代码中,尚不清楚您为什么import乌龟(两次)。