AttributeError的:“诠释”对象有没有属性“_erase”(AttributeError

2019-11-05 11:16发布

我试图做一个游戏,你必须避免从天空中掉落的物品。 我是一个初学者程序员(14yrs岁),所以我做了很多错误。 我解决了所有的人(这个节目),但我不知道如何解决这一问题之一。 该错误是在标题。 谢谢。 全码:

from livewires import games, color
import random

games.init(screen_width = 1280, screen_height = 720, fps = 150)

class Covjek(games.Sprite):
    def update(self):
        if self.overlapping_sprites:
            self.destroy()
            games.screen.quit()
        self.x = games.mouse.x
        if self.left < 0:
            self.left = 0
        if self.right > games.screen.width:
            self.right = games.screen.width

class Budala(games.Sprite):
    odds_change = 200
    def __init__(self, y = 50, speed = 2, odds_change = 200):
        super(Budala, self).__init__(image = games.load_image("nigga.jpg"),
                                 x = games.screen.width/2,
                                 y = y,
                                 dx = speed)
        self.odds_change = odds_change
        self.time = 200
        self.score = 0
        games.screen.add(self.score)
        self.text = games.Text(size = 50, x = games.screen.width - 20,
                               y = games.screen.height - 20, value = self.score,
                               color = color.red)    

    def update(self):
        if self.right > games.screen.width:
            self.dx = -self.dx
        if self.left < 0:
            self.dx = -self.dx
        odd = random.randrange(Budala.odds_change + 1)
        if odd == Budala.odds_change:
            self.dx = -self.dx
        self.time -= 1
        if self.time == 0:
            games.screen.add(Meteor(image = games.load_image("smeg.jpg"),
                                     x = self.x,
                                     y = self.y,
                                     dy = 2))
            self.time = 200



class Meteor (games.Sprite):

def __init__(self, chef, x = 640, y = 670,image = games.load_image("kamijonhehe.jpg")):
    super(Meteor, self).__init__(x = x,
                                  image = image,
                                  y = y,
                                  chef = budala)
    self.chef = chef
def update(self):
    if self.bottom > games.screen.height:
        self.destroy()
        self.chef.score += 1

games.screen.background = games.load_image("boaj.jpg")
budala = Budala()
games.screen.add(budala)                                      
games.screen.add(Covjek(image = games.load_image("kamijonhehe.jpg"),
                        x = games.screen.width/2,
                        bottom = 720))
games.screen.event_grab = True
games.mouse.is_visible = False
games.music.load("smukwed.mp3")
games.music.play()
games.music.play()
games.screen.mainloop()

完整的错误代码:

Traceback (most recent call last):
  File "C:\Users\nikol\Desktop\Python\prugrami limun\izbegavalje.py", line 
75, in <module>
    games.screen.mainloop()
  File "C:\Python31\lib\site-packages\livewires\games.py", line 303, in 
mainloop
    object._erase()
AttributeError: 'int' object has no attribute '_erase'

PS一些的话是在塞尔维亚,因此他们可能很难记。 在Python 3.1工作,Pygame的1.9.1和livewires。 线games.screen.mainloop()抛出的错误。

文章来源: AttributeError: 'int' object has no attribute '_erase'