Sprite.Frame.Contains 在 Objective C 中?

Sprite.Frame.Contains in Objective C?

所以我需要在我的游戏中做这行简单的代码。它目前在 swift 中,我正在尝试将其转换为 Objective-C 但我卡住了,因为在 Objective C 中没有

sprite.frame.cointains(//CGPOINT);

我想知道我该如何继续做这件事,因为这对我的比赛至关重要。 这是 swift

中的代码
    if fruitNode.frame.contains(location!) {
        touchPoint = location!
        touching = true
    }

如果有人能帮我回复,将不胜感激!

谢谢!

在 Objective C 中,您可以使用 SKNode 方法做到这一点:

if ([fruitNode containsPoint:location])
{
   // do this
}

或者如果您出于某种原因需要使用 CGRect

if (CGRectContainsPoint(fruitNode.frame, location))
{
  // do this
}

一定要查看 CGRectContainsPoint 的 Apple 参考 - https://developer.apple.com/library/prerelease/ios/documentation/GraphicsImaging/Reference/CGGeometry/index.html#//apple_ref/c/func/CGRectContainsPoint