cocos2d python 无法在 mac 中显示 UI



当我从终端在 mac Pro 中运行cocos2d(python) hello 示例时,我使用 sudo,但没有 UI 显示,没有警告没有错误,我错过了什么?

当我第一次运行MacPro x64时,它运行良好,但后来当我重新安装一些软件包时,它没有。也许 pyglet 的 1.1.4 版本不能支持 x64,但我不是很确定。

#
# cocos2d
# http://cocos2d.org
#
# This code is so you can run the samples without installing the package
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
#
import cocos
class HelloWorld(cocos.layer.Layer):
    def __init__(self):
        super( HelloWorld, self ).__init__()
        # a cocos.text.Label is a wrapper of pyglet.text.Label
        # with the benefit of being a cocosnode
        label = cocos.text.Label('Hello, World!',
            font_name='Times New Roman',
            font_size=32,
            anchor_x='center', anchor_y='center')
        label.position = 320,240
        self.add( label )
if __name__ == "__main__":
    # director init takes the same arguments as pyglet.window
    cocos.director.director.init()
    # We create a new layer, an instance of HelloWorld
    hello_layer = HelloWorld ()
    # A scene that contains the layer hello_layer
    main_scene = cocos.scene.Scene (hello_layer)
    # And now, start the application, starting with main_scene
    cocos.director.director.run (main_scene)
    # or you could have written, without so many comments:
    #      director.run( cocos.scene.Scene( HelloWorld() ) )

在Mac OSX Mavericks上,它使用sudo工作。没有sudo,我遇到了同样的问题。

sudo python samples/hello_world.py

最新更新