los-cocos / cocos

graphic library for games and multimedia, for python language on PC-like hardware
http://los-cocos.github.io/cocos-site/
Other
632 stars 146 forks source link

The layer size cannot match the window on MacBook #358

Open MTurandot opened 1 year ago

MTurandot commented 1 year ago

I am a beginner and now trying a script list on my M1 MacBook Air as following:

import cocos

class MainLayer(cocos.layer.ColorLayer):
    def __init__(self):
        super().__init__(255, 128, 128, 128)

        label = cocos.text.Label('Hello World!', font_size=64, anchor_x="right", anchor_y="top")
        label.position = 800, 600
        self.add(label)

if __name__ == '__main__':
    cocos.director.director.init(resizable=True, width=800, height=600, caption='cocos_hello_world')
    cocos.director.director.run(cocos.scene.Scene(MainLayer()))

The result:

截屏2023-06-26 15 16 17

After that, I have also tried:

import cocos

class MainLayer(cocos.layer.ColorLayer):
    def __init__(self):
        super().__init__(255, 128, 128, 128)

        label = cocos.text.Label('Hello World!', font_size=64, anchor_x="right", anchor_y="top")
        label.position = 800, 600
        self.add(label)

        self.anchor_x = 0
        self.anchor_y = 0
        self.scale = 2

if __name__ == '__main__':
    cocos.director.director.init(resizable=True, width=800, height=600, caption='cocos_hello_world')
    cocos.director.director.run(cocos.scene.Scene(MainLayer()))

but it did not work, either. Could someone tell me what the problem is and how to solve it? Thanks

My environment:

macOS Ventura 13.4 Python 3.10 cocos2d 0.6.9 pyglet 1.5.27

shayneoneill commented 1 year ago

Yeah I have the same problem :/

shayneoneill commented 1 year ago

Hmm. Seems like the solution is to use pyglet 2.x, but that seems incompatible with Cocos2d. Feels like a no-win scenario at this point. Unfortunate, Cocos is hands down the best game engine on python, but this doesnt seem like a solveable problem at least for my skillset. (Lots of OpenGL stuff in there that I have no idea how it works)

LeoLee98 commented 11 months ago

Yeah I have the same problem