OGeek|极客世界-中国程序员成长平台

标题: objective-c - 在 Cocos2D、iOS 中绘制填充动态多边形 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 11:35
标题: objective-c - 在 Cocos2D、iOS 中绘制填充动态多边形

如何在 cocos2D 框架中使用从 NSMutableArray 对象读取的点绘制多边形?

我可以使用这个函数绘制多边形:filled antialiased poly cocos2d

问题是因为 points 参数 *(CGPoint poli) 必须是静态对象。

有什么想法或建议吗?



Best Answer-推荐答案


NSMutableArray 对象的类型是什么? 您需要提取点的原始数据并将其设置为 poli 参数。 如果是 NSValueCGPoint 那么:

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);

关于objective-c - 在 Cocos2D、iOS 中绘制填充动态多边形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9260131/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4