获取SKPath中SKPoint的索引(Get index of an SKPoint in an SKPath)

编程入门 行业动态 更新时间:2024-10-12 16:29:15
获取SKPath中SKPoint的索引(Get index of an SKPoint in an SKPath)

我没有看到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.

更多推荐

本文发布于:2023-07-17 13:06:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1144911.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:索引   SKPath   SKPoint   index

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!