如何检测Sprite Kit tvOS中的触摸

时间:2016-03-04 10:01:12

标签: sprite-kit tvos

我有一个iOS Sprite Kit应用程序,它有几个节点四处移动,你必须点击正确的节点来获得一个点。我使用过这种方法:

- (void)touchesBegin:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    SKNode *targetNode = [self nodeAtPoint:[touch locationInNode:self]];
    // Codes to check whether the user tapped the correct nodes goes here.
}

现在我想将我的应用移植到tvOS。一切都很好,但接触。但你怎么能用它来检测触摸呢?

1 个答案:

答案 0 :(得分:3)

There is no equivalent to "touching" on tvOS because the user is using either a remote or a game controller.

You will need to design and implement an alternative user interface to provide visual feedback and react to actions on the remote (or game controller).

Apple recommends against using a "cursor" approach so you will need to be creative to find a solution that meets your game's requirements. Given that thumb movements on the remote's touch area are not as reactive vertically as they are horizontally, a cursor is very difficult to control for users.

If your game can have a notion of "Focus", there may be some workable solution. Otherwise, the port to tvOS will be a challenge.