【发布时间】:2026-02-12 09:25:02
【问题描述】:
我想检测触摸并在触摸精灵时对其做出反应,但我不希望使用它自己的类来覆盖它(因此,在 touchesBegan 方法中处理)。我只是希望它被视为场景中的另一个精灵。我目前正在这样做:
UITouch * touch = [touches anyObject];
CGPoint location = [touch locationInNode:self];
SKSpriteNode *touchedNode = (SKSpriteNode *)[self nodeAtPoint:location];
if(touchedNode == self.AnswerButton) {
NSLog(@"ANSWER button pressed.");
return;
}
if(touchedNode == self.HangupButton) {
NSLog(@"HANGUP button pressed.");
[self hangUp];
return;
}
但是,我想知道是否有更直接的方法来访问 self.HangupButon 和 self.AnswerButton 子精灵的触摸?
【问题讨论】:
标签: objective-c events sprite-kit touch sprite