我正在製作一個遊戲,其中您點擊一個硬幣並獲得硬幣,而我正在嘗試顯示您獲得的硬幣數量,但不會顯示。Pygame如何顯示一個變量?
代碼:
text = basicFont.render(str(coins), True, WHITE, BLACK)
textRect = text.get_rect()
textRect.centerx = windowSurface.get_rect().centerx
textRect.centery = windowSurface.get_rect().centery
你的答案沒有用。我用下面的代碼:#中設置的文本 文本= basicFont.render(STR(硬幣),真,白,黑) textRect = text.get_rect() textRect.centerx = 240 textRect.centery = 240 windowSurface.blit(text,(x1,y1) pygame.display.flip()它說它有無效的語法 – AnonymousPerson 2015-02-09 23:15:53
@AnonymousPerson請在你的問題中發佈完整的回溯作爲編輯 – 2015-02-10 00:10:50
當我運行它時,它說「語法無效「,pygame.display.flip中的pygame顯示爲紅色。 – AnonymousPerson 2015-02-11 21:18:21