applyImpulse不工作

知识的领域是无限的,我们的学习也是无限期的。这篇文章主要讲述applyImpulse不工作相关的知识,希望能为你提供帮助。
【applyImpulse不工作】我有一个SKShapeNode,我无法应用冲动。我的问题是什么?谢谢
码:

var ball = SKShapeNode()ball.path = UIBezierPath(roundedRect: CGRect(x:-ballWidth/2, y: -ballHeight/2, width: ballWidth, height: ballHeight), cornerRadius: 64).cgPath ball.position = CGPoint(x: self.frame.width / 2, y: self.frame.height / 2) ball.physicsBody = SKPhysicsBody(circleOfRadius: CGFloat(ballWidth / 2)); ball.physicsBody?.affectedByGravity = false ball.physicsBody?.isDynamic = false ball.physicsBody?.categoryBitMask = ballCategory ball.physicsBody?.collisionBitMask = enemyCategory ball.physicsBody?.contactTestBitMask = enemyCategory ball.isHidden = false ball.fillColor = UIColor.blue ball.strokeColor = UIColor.white ball.lineWidth = 10 ball.name = "ball" ball.zPosition = 0addChild(ball)ball.physicsBody?.applyImpulse(CGVector(dx: 50, dy: 50))

答案ball.physicsBody?.isDynamic = false意味着忽视冲动和其他力量。您需要将此设置为true。

    推荐阅读