Drawing primitive shapes with Cocos2d-python

702 views
Skip to first unread message

maxxim

unread,
Apr 21, 2015, 9:50:03 AM4/21/15
to cocos-...@googlegroups.com
Hello. I am starting to work with Cocos2d (Python implementation). How do we draw simple shapes? I checked out draw.py submodule and found a Canvas class and a Line class. Seems that this module is not finished yet. There's a primitives.py file in the tools dir, it has implemetation of primitive shapes, but on a lower level (with Pyglet). I want to create a Cocos node object using this code and be able to attach it to a Scene. But I have no idea how to do it. Any advice, please?

ottop

unread,
May 4, 2015, 1:54:01 PM5/4/15
to cocos-...@googlegroups.com
Reading this discussion might help you: https://groups.google.com/forum/#!topic/cocos-discuss/Ks83VdBj9Wk

I think with cocos2d you usually draw the node in its draw() function which you can implement as you like -- could be drawing some simple shape. When the node has been added to a Scene, its draw() function is called when the scene is drawn. Pyglet can be used for drawing. You could look at the implementation of Canvas or ColorLayer for example.

I haven't tried Canvas, but to me it looks good for drawing simple shapes.
Reply all
Reply to author
Forward
0 new messages