2017-03-18 14 views
2

私は現在スプライトノードで次のコードを実行しています。スプライトを停止するサークル上を移動すると回転しますか?

// the circle path's diameter 
    let circleDiameter = CGFloat(150) 

    // center our path based on our sprites initial position 
    let pathCenterPoint = CGPoint(
     x: player.position.x - circleDiameter/2, 
     y: player.position.y - circleDiameter/2 
    ) 

    // create the path our sprite will travel along 
    let circlePath = CGPath(ellipseIn: CGRect(origin: pathCenterPoint, size: CGSize(width: circleDiameter, height: circleDiameter)), transform: nil) 

    // create a followPath action for our sprite 
    let followCirclePath = SKAction.follow(circlePath, asOffset: false, orientToPath: true, duration: 4) 

    // make our sprite run this action forever 
    player.run(SKAction.repeatForever(followCirclePath)) 
    self.addChild(player) 

現在のところ、コードは正常に動作しますが、プレーヤは円の軌跡を描くように回転します。とにかく、円で動くように、プレーヤーのスプライトも回転しないようにすることはできますか?

乾杯:これに

let followCirclePath = SKAction.follow(circlePath, asOffset: false, orientToPath: true, duration: 4) 

::ちょうどfalseに設定orientToPath

let followCirclePath = SKAction.follow(circlePath, asOffset: false, orientToPath: false, duration: 4) 

D

答えて

関連する問題