[英]How can I blit the frame rate on my screen with pygame?
我知道我可以使用print(clock.get_fps())
在 shell 中打印 fps,但我想在播放时在屏幕上对 fps 进行 blit。
我试着用
fps_text = game_font.render(clock.get_fps(), True, (255, 255, 0))
win.blit(fps_text, (1000, 100))
(字体已经初始化,我在程序的其他地方使用它)
我收到错误TypeError: text must be a unicode or bytes
for the first line of code。 有没有办法做我想做的事? 感谢您的回答
clock.get_fps()
返回一个float
。 ' render
' 的第一个参数必须是str
。
改为: game_font.render(str(clock.get_fps()), True, (255, 255, 0))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.