请帮助我的抽象接触开始的方法。我在现场有这样的方法,VZChurch,这是SKSpriteNode。在SKSpriteNode的子类中是否有方法来转移开始的方法,因为我认为5-6如果其他语句不发光决定,所以我试图在SKSpriteNode的每个子类中找到迁移接触开始方法的方法。
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInNode:self.mapStaticGeometry];
SKNode *node = [self.mapStaticGeometry nodeAtPoint:location];
if ([node.name isEqualToString:@"church"]) {
VZChurch *obj = (VZChurch *)node;
obj.requestedAnimation = VZAnimationStateTouch;
[obj runAnimation];
} else if ...n iterations
}发布于 2014-03-17 19:10:30
避免所需内容的最佳方法是为每个节点子类一个SKNode (或SKSpriteNode)。这样您就可以在子类节点中处理touchesBegan。
因此,只需子类SKNode (或者SKSpriteNode,因为VZChurch是一个精灵),并在VZChurch的方法文件中处理touchesBegan --它是自己的方法文件。然后,如果您有其他的SKSprites,那么做同样的事情,对每个sprite进行子类化,并在各自的子类方法文件中处理touchesBegan。
https://stackoverflow.com/questions/22436316
复制相似问题