Hello,

Glad you give cocos a try.

The solution to your problem is quite simple. You've named your file 
`cocos.py`. So when importing cocos, Python only imports your file itself. 
Rename it to something else, and you won't have this problem. :)

Cheers,
Dan.

Le vendredi 5 février 2016 02:21:15 UTC+1, Michael Calvey a écrit :
>
> Hello all,
>
> I am brand new to cocos, and I am trying to find the best engine/ library 
> for a top down game I am about to start working on. While going through the 
> hello world exercise in the docs, I am receiving an AttributeError.
>
> Here is the code:
> 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)
>
> And the traceback:
> Traceback (most recent call last):
>   File "/Users/michaelcalvey/Documents/cocos.py", line 1, in <module>
>     import cocos
>   File "/Users/michaelcalvey/Documents/cocos.py", line 4, in <module>
>     class HelloWorld(cocos.layer.Layer):
> AttributeError: module 'cocos' has no attribute 'layer'
>
> Thanks a lot for the help, sorry if it is an obvious problem but I have 
> looked around and haven't found anything relevant.
> I am really looking forward to getting this to work!
>
> Michael
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"cocos2d discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/cocos-discuss.
For more options, visit https://groups.google.com/d/optout.

Reply via email to