使用物理移动 SKSpriteNodes 碰撞行为

Moving SKSpriteNodes collision behaviour with physics

我正在制作一个游戏,其中玩家通过向玩家施加力(玩家应该向左还是向右移动由 xVelocity 值决定,它是 -200 或 200)在世界各地移动更新方法。

override func update(currentTime: NSTimeInterval) {
    player?.physicsBody?.applyForce(CGVectorMake(xVelocity, 0))
    enemy?.physicsBody?.applyForce(CGVectorMake(enemyxVelocity, 0))
}

我也有一些移动的敌人,也在 x 轴上使用力。当敌人和玩家发生碰撞时,敌人被击退而玩家能够继续移动,但这与我想要的相反。我希望敌人的动量更强大,并真正将玩家推开。

我正在使用 Xcode 的场景编辑器来制作这个,但我不确定物理体属性的哪些部分与给我所需的效果相关?

尝试调整游戏中每个角色的质量

https://developer.apple.com/library/ios/documentation/SpriteKit/Reference/SKPhysicsBody_Ref/index.html#//apple_ref/occ/instp/SKPhysicsBody/mass

"The mass property determines how forces affect the body, as well as how much momentum the body has when it is involved in a collision."