SpriteKit physicsBody applyImpulse节点失败(SpriteKit physicsBody applyImpulse node fails)
我正在尝试在触摸屏操作上创建跳转事件,但在applyImpulse之后,我的精灵会通过另一个(在屏幕底部)失败。 有些参数看起来不错,但有时会发生。
码:
[self.physicsBody applyImpulse:CGVectorMake(dx / mag * kImpuleScale,20.0f)];
I'm trying to create a jump event on touch screen action, but after applyImpulse my sprite is fails through another(which at the bottom of the screen). With some parameters everything looks good, but sometimes it happen.
Code:
[self.physicsBody applyImpulse:CGVectorMake(dx/mag*kImpuleScale, 20.0f)];
最满意答案
你可以将物理身体放在你的屏幕上,只需:
var borderBody = SKPhysicsBody(edgeLoopFromRect: self.frame) self.physicsBody = borderBody然后没有身体可以“逃脱”
you can put a physicsBody around your Screen simply with:
var borderBody = SKPhysicsBody(edgeLoopFromRect: self.frame) self.physicsBody = borderBodyThen no body can "escape"
更多推荐
发布评论