Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在外星入侵游戏中,为什么这个错误显示';pygame.Rect';对象没有属性';得到正确的答案'&引用;?_Python_Python 3.x_Pygame_Pygame Surface - Fatal编程技术网

Python 在外星入侵游戏中,为什么这个错误显示';pygame.Rect';对象没有属性';得到正确的答案'&引用;?

Python 在外星入侵游戏中,为什么这个错误显示';pygame.Rect';对象没有属性';得到正确的答案'&引用;?,python,python-3.x,pygame,pygame-surface,Python,Python 3.x,Pygame,Pygame Surface,在外星人入侵游戏中,为什么会出现下面的错误 “pygame.Rect”对象没有属性“get_Rect” 导入pygame 从pygame.sprite导入sprite 类外星人(精灵): 定义初始化(自我、ai设置、屏幕): super()。\uuuu init\uuuuu() self.screen=screen self.ai_设置=ai_设置 #外星影像 self.image=pygame.image.load('images/alien.bmp') self.rect=self.ima

在外星人入侵游戏中,为什么会出现下面的错误

“pygame.Rect”对象没有属性“get_Rect”

导入pygame
从pygame.sprite导入sprite
类外星人(精灵):
定义初始化(自我、ai设置、屏幕):
super()。\uuuu init\uuuuu()
self.screen=screen
self.ai_设置=ai_设置
#外星影像
self.image=pygame.image.load('images/alien.bmp')
self.rect=self.image.get_rect()
#屏幕顶部的新外星人
self.rect.x=self.rect.width
self.rect.y=self.rect.height
#外国人的地位
self.x=float(self.rect.x)
def blitme(自):
self.screen.blit(self.image、self.rect)
def检查_边(自):
#如果在屏幕年龄为外国人,则为true
screen\u rect=self.screen.get\u rect()
如果self.rect.right>=屏幕右对齐:
返回真值

elif self.rect.left屏幕是一个pygame.rect对象,如前所述,它没有get\u rect方法。您需要将曲面对象传递到屏幕,而不是Rect对象

见:


屏幕是一个pygame.Rect对象,如上所述,它没有get\u Rect方法。您需要将曲面对象传递到屏幕,而不是Rect对象

见:


如何创建
Alien
的实例?似乎一个
pygame.Rect
对象被传递到
Alien
的构造函数的参数
screen
。如何创建
Alien
的实例?似乎一个
pygame.Rect
对象被传递到
Alien
的构造函数的参数
screen