我没有看到SKPath.Points的IndexOf或FindIndex方法。 我需要能够在指定点的两侧获得相邻点。 Path.Iterator只有.Next,所以我正在寻找使用SKPoint的索引。
随着IndexOf或FindIndex似乎丢失,我想在后台继承和维护第二个数据集以获取索引。
我错过了明显的东西吗? 到目前为止,其他人如何获得索引?
I'm not seeing an IndexOf or FindIndex method for SKPath.Points. I need to be able to get neighbouring points on both sides of a specified point. Path.Iterator only has .Next, so I am looking for using the index of the SKPoint instead.
With IndexOf or FindIndex seemingly missing, I am thinking of inheriting and maintaining a 2nd dataset in the background for getting the index.
Am I missing something obvious? How are others getting the index, so far?
最满意答案
这篇文章有帮助。 在Array上直接调用IndexOf。 只需确保您的SKPoint X和Y与存储在SKPath.Points中的其他SKPoints是唯一的。 它正在根据SKPoint的位置进行检查,因此,例如,如果您在(0,0)处有多个SKPoint,它将返回该位置的第一个SKPoint。
幸运的是,我不应该为我的用例而处于这种情况。
This post helped. Calling IndexOf directly on Array works. Just need to make sure your SKPoint X and Y are unique from other SKPoints stored in the SKPath.Points. It is doing the check based on the SKPoint's position, so if you have multiple SKPoints at (0, 0), for example, it will return the first one at that position.
Luckily, I should never be in the situation for my use case.
更多推荐
发布评论