pycharm cannot find reference 'layer' in '__init__.py' for cocos2d

4.5k views Asked by At

I am just starting out to learn cocos2d using python.

When I write this in pycharm :

import cocos

class HelloWorld(cocos.layer.Layer):
def __init__(self):
    super(HelloWorld, self).__init__()
    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)
cocos.director.director.init()
hello_layer = HelloWorld()
main_scene = cocos.scene.Scene(hello_layer)
cocos.director.director.run(main_scene)

Pycharm shows the error cannot find reference 'layer' in '__init__.py' but when I run it, the code works. The code works even when run from inside pycharm (not via terminal), although I don't find it surprising, but thought maybe it requires mentioning. It also doesn't gives any auto-suggestions and/or auto-completes anything related to cocos2d.

Any idea on how to fix this ?

I am using python 3.4.

0

There are 0 answers