斌小白 发表于 2020-12-13 22:27:09

PYGAME已解决

本帖最后由 斌小白 于 2020-12-16 08:40 编辑

elif life_num == 0:
            pygame.mixer.music.stop()
            # 背景音乐停止
            pygame.mixer.stop()
            # 停止全部音效
            pygame.time.set_timer(SUPPLY_TIME, 0)
            # 停止发放补给
            if not recorded:
            # 如果没有打开文本
                recorded = True
                with open('record.txt', 'r') as f:
                  record_score = int(f.read())
                # 读取历史最高得分
                if score > record_score:
                  with open('record.txt', 'w') as f:
                        f.write(str(score))
                # 如果玩家得分高于历史最高得分,则存档
      # 游戏结束设置

      record_score_text = score_font.render('Best : %d' % record_score, True, (255, 255, 255))
      screen.blit(record_score_text, (50, 50))
出现UnboundLocalError: local variable 'record_score' referenced before assignment怎么解决

斌小白 发表于 2020-12-14 09:22:52

找到问题了,不用麻烦看了{:5_108:}

昨非 发表于 2020-12-14 16:39:25

斌小白 发表于 2020-12-14 09:22
找到问题了,不用麻烦看了

自己解决的帖子
请点击左下角【编辑】,重新设置帖子类型为【已解决】
以避免对别人回答问题造成干扰
页: [1]
查看完整版本: PYGAME已解决