cocos2d 如何隐藏默认标题
如题,代码如下import cocos
class HelloWorld(cocos.scene.Scene):
def __init__(self):
cocos.scene.Scene.__init__(self)
label = cocos.text.Label('Hello 歌者', anchor_x='left', anchor_y='top')
label.position = (0, 0)
self.add(label)
if __name__ == '__main__':
cocos.director.director.init(width=640, height=480, caption='Threebody')
bye = HelloWorld()
cocos.director.director.run(cocos.scene.Scene(bye))
上面的标题“threebody”如何隐藏,就是不显示,只显示窗口 你把 caption 设成空字符串不行吗?
import cocos
class HelloWorld(cocos.scene.Scene):
def __init__(self):
cocos.scene.Scene.__init__(self)
label = cocos.text.Label('Hello 歌者', anchor_x='left', anchor_y='top')
label.position = (0, 0)
self.add(label)
if __name__ == '__main__':
cocos.director.director.init(width=640, height=480, caption='')
bye = HelloWorld()
cocos.director.director.run(cocos.scene.Scene(bye))
isdkz 发表于 2023-2-27 18:09
你把 caption 设成空字符串不行吗?
不行……这样显示了一个空标题,比原来还难看 歌者文明清理员 发表于 2023-2-27 18:11
不行……这样显示了一个空标题,比原来还难看
你是不想要标题栏? isdkz 发表于 2023-2-27 18:14
你是不想要标题栏?
是,看来我的表述不正确 歌者文明清理员 发表于 2023-2-27 18:17
是,看来我的表述不正确
好像没有别的办法,只能通过设成全屏模式实现
import cocos
class HelloWorld(cocos.scene.Scene):
def __init__(self):
cocos.scene.Scene.__init__(self)
label = cocos.text.Label('Hello 歌者', anchor_x='left', anchor_y='top')
label.position = (0, 0)
self.add(label)
if __name__ == '__main__':
cocos.director.director.init(caption='Threebody', fullscreen=True)
bye = HelloWorld()
cocos.director.director.run(cocos.scene.Scene(bye))
本帖最后由 dolly_yos2 于 2023-2-27 18:48 编辑
从 cocos2d 的文档看,cocos.director.director.init 支持的参数是 pyglet.window.Window 的超集
pyglet.window.Window 有一个 style 参数,可以设置为 pyglet.window.Window.WINDOW_STYLE_BORDERLESS,可能能建议窗口管理器将窗口装饰为无边框模式
https://los-cocos.github.io/cocos-site/doc/api/cocos.director.html#initializing
https://los-cocos.github.io/cocos-site/doc/api/cocos.director.html#cocos.director.Director.init
https://pyglet.readthedocs.io/en/latest/modules/window.html?highlight=ScreenMode#pyglet.window.Window
https://pyglet.readthedocs.io/en/latest/modules/window.html?highlight=ScreenMode#pyglet.window.Window.WINDOW_STYLE_BORDERLESS dolly_yos2 发表于 2023-2-27 18:43
从 cocos2d 的文档看,cocos.director.director.init 支持的参数是 pyglet.window.Window 的超集
pyglet.w ...
在director.init里加了个style='borderless'就行了!谢谢!
页:
[1]