为了账号安全,请及时绑定邮箱和手机立即绑定

pygame.error: font not initialized 如何修复?

pygame.error: font not initialized 如何修复?

猛跑小猪 2023-04-25 17:11:41
所以我有这个错误 pygame.error: font not initialized 我已经厌倦了通过缩进它来修复它,未识别它,更改字体和其他东西但它仍然无法在我的 STARTMENUE 上工作。我也尝试过使用另一种字体,认为这是问题所在,但事实并非如此。我有问题吗largeText = pygame.font.Font('freesansblod.ttf',115)我的完整代码import pygame#set screenwindow = pygame.display.set_mode((500,500))#set Namepygame.display.set_caption("Noob")class Player:    def __init__(self,x,y,height,width,color):        self.x = x        self.y = y        self.height = height        self.color = color        self.speed = 0        self.isJump = False        self.JumpCount = 10        self.fall = 0        self.rect = pygame.Rect(x,y,height,width)    def draw(self):        self.topleft = (self.x,self.y)class Floor:    def __init__ (self,x,y,height,width,color):        self.x = x        self.y = y        self.height = height        self.width = width        self.color = color        self.rect = pygame.Rect(x,y,height,width)    def draw(self):        self.topleft = (self.x,self.y)        pygame.draw.rect(window,self.color,self.rect)class Coin():    def __init__(self,x,y,height,width,color):        self.x = x        self.y = y        self.width = width        self.height = height        self.color = color        self.rect = pygame.Rect(x,y,height,width)    def draw(self):        self.topleft = (self.x,self.y)        self.draw.rect(self.color,self.rect)    white = (255,255,255)green = (0,200,0)red = (255,0,0)drakred = (200,0,0)darkgreen = (0,200,0)black = (0,0,0) player1 = Player(50,400,40,40,white)coin = Coin(100,300,30,30,red)floor1 = Floor(0,400,600,30,green)fps = (30)clock = pygame.time.Clock()
查看完整描述

1 回答

?
天涯尽头无女友

TA贡献1831条经验 获得超9个赞

尝试在导入 pygame 的位置下方添加 pygame.font.init() 。



查看完整回答
反对 回复 2023-04-25
  • 1 回答
  • 0 关注
  • 92 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信