Cocos2dx- Draw primitives(polygons) on Update

Posted by Haider on Game Development See other posts from Game Development or by Haider
Published on 2013-11-06T17:15:53Z Indexed on 2013/11/06 22:10 UTC
Read the original article Hit count: 419

Filed under:
|

In my game I'm trying to draw polygons on on each step i.e. update method. I call draw() method to draw new polygon with dynamic vertices. Following is my code:

  void HelloWorld::draw(){glLineWidth(1);CCPoint filledVertices[] = {ccp(drawX1,drawY1),ccp(drawX2,drawY2), ccp(drawX3,drawY3), ccp(drawX4,drawY4)};ccDrawSolidPoly( filledVertices, 4, ccc4f(0.5f, 0.5f, 1, 1 ));}

I call the draw() method from the update(float dt) method. The engine is behaving inconsistently i.e. sometimes it displays the polygons and on other occasions it does not.

Is it the right approach to do such a task? If not what is the best way to display large number of primitives?

© Game Development or respective owner

Related posts about cocos2d

Related posts about cocos2d-x