Spritekit重置场景问题

时间:2015-04-06 03:44:01

标签: ios objective-c sprite-kit skscene

我正在尝试按下一个按钮,按下该按钮将重置场景。按钮工作正常但是第二次,某些节点处于不同的位置并且物理接触被触发。这是我的代码

    -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
/* Called when a touch begins */



    if (inGame == false) {

        inGame = true;
        gravity = -7;
        SKAction *wait = [SKAction waitForDuration:1.5];
        SKAction *moveOff = [SKAction moveBy:CGVectorMake(-25000, 0) duration:100];
        SKAction *sequence = [SKAction sequence:@[wait, moveOff]];
        [startRamp runAction:sequence];
        [tapToStart runAction:sequence];

        SKSpriteNode *ball = [SKSpriteNode spriteNodeWithImageNamed:@"Ball"];
        ball.position = CGPointMake(CGRectGetMaxX(self.frame)/(CGRectGetMaxX(self.frame)/64), CGRectGetMidY(self.frame)*1.3);
        ball.scale = CGRectGetMaxX(self.frame)/((CGRectGetMaxX(self.frame)*8));
        ball.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius:ball.size.width/2];
        ball.physicsBody.categoryBitMask = playerMask;
        ball.physicsBody.contactTestBitMask = playerMask2;
        [self addChild:ball];

        nodeLocation = ball;
        ball = nodeLocation;

    }

    else if (timeCountStart >= 90) gravity *= -1;


    else if (moveNextScene == true) {



        [self.view presentScene:self.scene transition:[SKTransition doorwayWithDuration:2]];

                }
moveNextScene = true;

       }

0 个答案:

没有答案