我需要知道如何在两三秒后使球减速以施加冲动
func setupPlayer(){
player = SKSpriteNode(imageNamed: "ball")
player.anchorPoint = CGPoint(x: 0.5, y: 0.5)
player.position = CGPoint(x: size.width/2, y: playableStart)
let scale: CGFloat = 0.07
player.xScale = scale
player.yScale = scale
player.physicsBody = SKPhysicsBody(circleOfRadius: player.size.width / 2)
worlNode.addChild(player)
}
func movePlayer(){
player.physicsBody?.applyImpulse((CGVectorMake( 50, 50)))
}
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
/* Called when a touch begins */
for touch in (touches as! Set<UITouch>) {
movePlayer()
}
}
答案 0 :(得分:0)
你在找这样的东西吗?
let wait = SKAction.waitForDuration(2.0)
let slow = SKAction.runBlock({
node.physicsBody?.applyImpulse(CGVectorMake(-node.physicsBody?.velocity.dx, -node.physicsBody?.velocity.dy))
//you will probably want to mess with the vector
})
node.runAction(SKAction.sequence([wait, slow]))
答案 1 :(得分:0)
减速物理体的一种方法是随时间降低其速度:
Please enter a valid URL address