如何在应用了这样的冲动后停止精灵:
player.physicsBody!.applyImpulse(CGVectorMake(50,0))
是否有可能使运动在一段时间内减少? (2秒)
解决方法
为了阻止physicsBody的移动,你可以使用’veLocity’变量,如下所示:
//this will reset the x,y based veLocity to a halt/stop player.physicsBody?.veLocity = CGVectorMake(0,0) //if you would also like to stop any rotation that may be present player.physicsBody?.angularVeLocity = 0
要解决第二个问题,你应该研究’lineardamping’来影响速度,’angulardamping’来影响angularVeLocity(旋转).这些physicsBody参数允许您在施加脉冲后随时间减慢速度(类似于摩擦).
//These values should be set when creating the physicsBody. //should experiment with these values to get the desired effect. player.physicsBody?.lineardamping = 1.10 player.physicsBody?.angulardamping = 0.25
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。