检查暂停的精灵套件场景上的操作

时间:2014-02-20 00:23:04

标签: sprite-kit

我在这里有这个代码,当我按下按钮时,它会暂停现场。我有一个else if语句,当我选择另一个按钮时它会恢复它。但是,当场景暂停时,我无法执行任何操作。

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
for (UITouch *touch in touches)
{
    SKTexture * playTexture = [SKTexture textureWithImageNamed:@"PlayButtonButton.png"];
    SKTexture * pausedTexture = [SKTexture textureWithImageNamed:@"PauseButtonButton.png"];

    SKSpriteNode *pause = (SKSpriteNode*)[self childNodeWithName:@"pause"];
    SKSpriteNode *play = (SKSpriteNode*)[self childNodeWithName:@"pausedd"];

    CGPoint location = [touch locationInNode:self];


    if([pause containsPoint:location])
    {
        [berry removeFromParent];
        [pause runAction:[SKAction setTexture:playTexture ] completion:^{
            [self.scene.view setPaused:YES];

        }];


    } else if ([play containsPoint:location]){
        [play runAction:[SKAction setTexture:pausedTexture] completion:^{
            [play removeFromParent];

            [self.scene.view setPaused:NO];

        }];

    }
}

}

1 个答案:

答案 0 :(得分:1)

pause.texture = playTexture;
self.scene.view.paused = YES;

此处无需采取任何措施。