python - pygame 中不断弹出弃用警告
问题描述
所以,我正在制作一款我遇到多个问题的游戏,因为这是我的第一个游戏。问题之一是,每当我打开它时,只会弹出一个-5,然后程序开始工作。我认为这是因为以下具体警告:
Warning (from warnings module):
File "C:/Users/LENOVO/Desktop/Everything Here!!/MoreCollision.py", line 57
win.blit(text, (250 -(text.get_width()/2), 200))
DeprecationWarning: an integer is required (got type float). Implicit conversion to integers using __int__ is deprecated, and may be removed in a future version of Python.
属于它的代码是:
def hit(self):
self.x = 60
self.y = 410
self.walkCount = 0
font1 = pygame.font.SysFont('comicsans', 100)
text = font1.render('-5', 1, (255,0,0))
win.blit(text, (250 -(text.get_width()/2), 200))
pygame.display.update()
i = 0
while i < 300:
pygame.time.delay(10)
i += 1
for event in pygame.event.get():
if event.type == pygame.QUIT:
i = 301
pygame.quit()
所以,我真的不知道如何解决它。如果有人可以,请提供帮助。
解决方案
删除写入屏幕的代码-5
以阻止其写入屏幕。这也解决了DeprecationWarning
因为它是由写入-5
屏幕的代码引起的!
推荐阅读
- javascript - 将 json 转换为 csv 时,标题值出现多次
- ruby-on-rails - Sprockets 和 rails-ujs:无法加载这样的文件——coffee_script
- ios - Swift 5 - Facebook 登录:LoginManager() 总是返回取消
- javascript - React Native:滚动视图中的平面列表 android 性能
- search - 如何轻松实现选择器:搜索 Meteor,使用 React 而不是 Blaze
- c# - 具有计算属性的 C# DTO
- drools - 我在 Drools 中遇到错误
- kubernetes - 如何将变量传递给 helm install --set 参数
- java - 尝试制作矩形循环时如何解决while循环(处理)中的问题
- python - Python 3.x - 使用 OpenCV 裁剪图像时出错