Ios 正在停止SKAction.applyForce
我有一个球在屏幕上弹跳,当调用touchesend函数时,球开始弹跳:Ios 正在停止SKAction.applyForce,ios,swift,sprite-kit,skaction,Ios,Swift,Sprite Kit,Skaction,我有一个球在屏幕上弹跳,当调用touchesend函数时,球开始弹跳: override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) { for touch in touches{ let location = touch.location(in: self) let ballposition = CGVector.init(dx: locatio
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
for touch in touches{
let location = touch.location(in: self)
let ballposition = CGVector.init(dx: location.x, dy: location.y - circle.position.y)
circle.run(SKAction.applyForce(ballposition, duration: 0.3), withKey: "move")
}}
在代码中,ball被命名为circle
我希望碰撞发生时动作SKAction.applyForce
停止
我得到了“命中”这个词,意思是检测工作正常,但是
圆圈移动(forKey:“移动”)
不工作,idk为什么
我尝试了
circle.removeAllActions()
。此圆是否与您添加操作的对象相同?
尝试
circle.paused=true
此圆是否与您添加操作的对象相同?
尝试
circle.paused=true
SKAction.applyForce
方法仅对物理实体应用力。移除该键将停止施加力,但不会移除当前效果。要停止实体,可以更改实体的速度向量:
circle.physicsBody?.velocity = CGVector.zero
SKAction.applyForce
方法仅对物理实体应用力。移除该键将停止施加力,但不会移除当前效果。要停止实体,可以更改实体的速度向量:
circle.physicsBody?.velocity = CGVector.zero
是的,圆圈与我添加到动作中的圆圈是同一个对象是的,圆圈与我添加到动作中的圆圈是同一个对象,这就是它背后的理念。谢谢,这就是它背后的想法。谢谢