我正在使用 pygame 撰寫我自己的Asteroids迷你游戲(使用多個精靈時效率極低,因此想使用執行緒。
如何通過我的主類(處理程式)類從另一個類(小行星類)訪問函式。
如果我的班級系統落后或無法使用 Threading,請向我解釋如何使其更高效或更易于編碼
class Asteroids():
def __init__(self):
....
def Update(self):
....
class Handler():
def __init__(self):
....
def Update_All(self):
x = threading.Thread(target = ##Asteroids.Update()
x.start()
提前致謝
uj5u.com熱心網友回復:
你需要創建一個 Asteroids 的實體
astroid = Astroids()
# then you can use the function in your thread
x = threading.Thread(target = astroid.Update())
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/518065.html
