【问题标题】:How to stop an object from losing its position when colliding with another physicbody如何在与另一个物理体碰撞时阻止物体失去位置
【发布时间】:2016-08-14 01:07:59
【问题描述】:

我的玩家对象在被另一个对象击中时总是会改变它的位置! 我不希望它那样做。我尝试将 player.physicbody?.dynamic 设置为 false,但我的对象完全停止移动。

【问题讨论】:

    标签: ios swift sprite-kit


    【解决方案1】:

    你必须查看三个physicsBody 属性,它们是categoryBitMask、collisionBitMask 和contactTestBitMask。首先声明一个这样的结构

    struct ColliderType {
    static let Player:      UInt32 = 0
    static let Destroyable: UInt32 = 0b1
    static let Wall:        UInt32 = 0b10
    static let Collectible: UInt32 = 0b100
    static let Trigger:     UInt32 = 0b1000
    static let Projectile:  UInt32 = 0b10000
    static let Enemy:       UInt32 = 0b100000
    static let None:        UInt32 = 0b1000000
    }
    

    n 然后在关于节点的情况下使用这个值。

    【讨论】:

    • 感谢刚刚将碰撞位掩码更改为零来解决这个问题!
    • 太棒了:),请接受我的回答,因为这会提高我的声誉:p
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多