在Cocos2D、iOS中绘制填充的动态多边形

发布于 2025-01-04 15:51:15 字数 250 浏览 3 评论 0原文

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

我可以使用此函数绘制多边形: 填充抗锯齿聚 cocos2d

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

有什么想法或建议吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

奢华的一滴泪 2025-01-11 15:51:15

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

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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文