このコードを実行すると、 "ValueError:size(int width、int height)にする必要があります"というエラーが表示されます。私は値800と600、同じエラーのために変数を代入しようとしたpygameの画面にテキストを追加する際に問題が発生しました
pygame.Surface.blit(pygame.Surface(display_width, display_height), welcomeMessageBackground, area = None, special_flags = 0)
display_width = 800
display_height = 600
welcomeScreen = pygame.display.set_mode((display_width, display_height))
red = (255, 0, 0)
white = (255, 255, 255)
welcomeScreen.fill(white, rect = None, special_flags = 0)
welcomeMessageBackground = pygame.draw.rect(welcomeScreen, red, [200, 100, 400, 75])
welcomeFont = pygame.font.Font(None, 50)
welcomeMessage = welcomeFont.render('Welcome! Click a button to get started.', True, white)
pygame.Surface.blit(pygame.Surface(display_width, display_height), welcomeMessageBackground, area = None, special_flags = 0)
pygame.display.update()
問題を引き起こす行があります。私が欲しいのは、welcomeMessageのテキストが矩形welcomeMessageBackground上に表示されることです。どんな助けもありがとう!