iOS 7:SpriteKit GestureRecognizer

时间:2013-10-25 13:59:53

标签: ios uigesturerecognizer sprite-kit

我有一个场景,我需要通过双击呈现另一个场景,但它不起作用((我犯错误或我知道有什么不对? 那段代码:

-(id)initWithSize:(CGSize)size {
if (self = [super initWithSize:size]) {
    /* Setup your scene here */

    self.backgroundColor = [SKColor colorWithRed:0.15 green:0.15 blue:0.3 alpha:1.0];

    SKLabelNode *myLabel = [SKLabelNode labelNodeWithFontNamed:@"Chalkduster"];

    myLabel.text = @"Kill Them All!";
    myLabel.fontSize = 30;
    myLabel.position = CGPointMake(CGRectGetMidX(self.frame),
            CGRectGetMidY(self.frame));
    myLabel.alpha = -2;
    SKAction *fadeIn = [SKAction fadeInWithDuration:9.0];
    [myLabel runAction:fadeIn];
    [self addChild:myLabel];


    UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doubleTap)];
    doubleTap.numberOfTapsRequired = 2;

    [self.view addGestureRecognizer:doubleTap];
}
return self;}

-(void)doubleTap{
NewScene *newScene = [[NewScene alloc] initWithSize:self.view.bounds.size];
SKTransition *doors = [SKTransition doorsOpenVerticalWithDuration:1.0];
[self.view presentScene:newScene transition:doors];}

1 个答案:

答案 0 :(得分:0)

如果我通过以下方式委托UIView:

-(id)initWithSize:(CGSize)size andWithView:(UIView *)view

有效! =)