我是程式設計課程的助教。本週的挑戰是建立一個基本的國際象棋遊戲。老師建了一個game.py
圖書館來幫助他們。問題是,當使用LostGame
類別時,其定義如下(並使用Arcade
庫):
class LostGame(arcade.Window):
def __init__(self):
super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
self.sprites_list = None
self.background = None
arcade.set_background_color(arcade.color.RED)
self.moves = []
self.doing = 0
self.started = 0
self.current_text = "Comienza el juego"
我們會出現以下錯誤:
Traceback (most recent call last):
File "test.py", line 4, in <module>
juego = game.LostGame()
File "/Users/daniel/Documents/Doctorado/Ayudantías/IIC2115/L02/game.py", line 39, in __init__
super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/arcade/application.py", line 53, in __init__
resizable=resizable, config=config)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyglet/window/__init__.py", line 643, in __init__
self._create()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/arcade/monkey_patch_pyglet.py", line 81, in _create
self.context.attach(self.canvas)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyglet/gl/cocoa.py", line 289, in attach
self._nscontext.setView_(canvas.nsview)
AttributeError: 'NoneType' object has no attribute 'setView_'
我們注意到,所有安裝了 Anaconda 的電腦都會發生此錯誤。我們認為這可能是因為 Anaconda 的 Python 無法辨識該Arcade
函式庫。我們已經在獨立版本的 上運行了程式碼Python 3.7
,但沒有成功。
在此先感謝您的幫忙!