重新加载场景后脉冲会发生变化

时间:2015-01-13 16:41:22

标签: swift sprite-kit skspritenode skphysicsbody skscene

我正在向SKSpriteNode' char'使用以下代码:

    randX = arc4random_uniform(20) - 10
    randXConv = CGFloat(randX)

    char.physicsBody?.velocity = CGVectorMake(0, 0)
    char.physicsBody?.applyImpulse(CGVector(dx: randXConv, dy: 23))

当游戏结束时,我呈现EndGameScene:

    let skView = self.view! as SKView

    let scene = EndGameScene(size: self.frame.size)
    scene.size = skView.bounds.size
    scene.scaleMode = .AspectFill

    let sceneTransition = SKTransition.crossFadeWithDuration(0.3)
    skView.presentScene(scene, transition: sceneTransition)

然而,重试后#39;在EndGameScene中按下按钮并再次显示GameScene,冲动不会使节点“char”#39;旅行时的行程与首次载入时一样高:

    let skView = self.view! as SKView

    let scene = GameScene(size: self.frame.size)
    scene.size = skView.bounds.size
    scene.scaleMode = .AspectFill

    let sceneTransition = SKTransition.crossFadeWithDuration(0.3)
    skView.presentScene(scene, transition: sceneTransition)

我认为这与场景或引力有关,但我可能是错的。 谢谢你的帮助。

0 个答案:

没有答案