2

How can i draw polygon with points read from NSMutableArray object in cocos2D framework?

I am able to draw polygon using this function: filled antialiased poly cocos2d

The problem is becouse points argument *(CGPoint poli) must be static object.

Any ideas or suggestions?

Community
  • 1
  • 1
knagode
  • 5,816
  • 5
  • 49
  • 65

1 Answers1

3

What is type of NSMutableArray objects? You need to extract raw data of points and set it as poli argument. If it's NSValue with CGPoint then:

NSMutableArray* yourPointsArray;
...
CGPoint* poli = malloc (sizeof (CGPoint) * [yourPointsArray count]);
for (uint i=0; i<[yourPointsArray count]; i++)
{
    poli[i] = [[yourPointsArray objectAtIndex: i] CGPointValue];
}
ccFillPoly (poli, [yourPointsArray count], YES);
free (poly);
brigadir
  • 6,874
  • 6
  • 46
  • 81