类型错误:无效的前景 RGBA 参数 [英] TypeError: Invalid foreground RGBA argument

查看:80
本文介绍了类型错误:无效的前景 RGBA 参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次尝试运行 Pygame 程序时,都会出现此错误:

Every time I try to run the Pygame program, I get this error:

TypeError: 无效的前景 RGBA 参数

TypeError: Invalid foreground RGBA argument

这是我的代码,你知道为什么吗?

Here is my code, do you have any idea why ?

text = font.render(b’Score:’ , dude.score, 1, (0, 0, 0))

推荐答案

as per the docs Font.render 将 rgb 作为他的第三个参数,你将它作为第四个参数传递.这不会引发正确的错误,因为 font.render 需要第四个可选参数背景.

as per the docs Font.render takes rgb as his third argument, you pass it as fourth. This does not raise a proper error because font.render takes a fourth optional argument background.

试试 text = font.render('Score:'+str(dude.score), 1, (0, 0, 0))

这篇关于类型错误:无效的前景 RGBA 参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆