未通过nodeAtPoint方法选择移动精灵

时间:2015-06-02 07:51:22

标签: animation sprite-kit touchesbegan skaction

所以我有精灵,它们在屏幕上随机生成,然后通过SKAction随机移动。

例如:

SKSpriteNode *sprite = [SKSpriteNode spriteNodeWithImageNamed:@"Icicle.png"];
sprite.position = CGPointMake (randomX, 0); //randomX is a random integer between 0 and screen width

SKAction *action = [SKAction moveToY:-200 duration:2];

[sprite runAction:action];

[self addChild:sprite];

现在我的触摸开始了方法:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

    UITouch *touch = [touches anyObject];

    CGPoint location = [touch locationInNode:self];

    SKNode *node = [self nodeAtPoint:location];

}

我所看到的是我的节点没有被非常准确地选中。 Icicle图像的四边缓冲宽度为20像素。

是否处于SKAction的中间,通过点击不准确来选择节点?

此外,有关如何通过touchesbegan方法选择不断移动的节点的任何建议吗?

0 个答案:

没有答案
相关问题