【问题标题】:Physics category struct in Sprite KitSprite Kit 中的物理类别结构
【发布时间】:2015-06-23 19:27:35
【问题描述】:

我一直在使用 Sprite Kit 及其物理特性制作游戏,并在教程中遇到了这个结构:

struct PhysicsCategory
{
    static let None: UInt32 = 0
    static let All: UInt32 = UInt32.max
    static let Player: UInt32 = 0b10
    static let Obstacle: UInt32 = 0b11
}

谁能告诉我 0b01 等是什么意思以及如何在这里创建一个新常量?

【问题讨论】:

    标签: ios swift uint32


    【解决方案1】:

    是hexa,即16进制数

    0b11 in hexa 是

    0 * 16^3 + 11 * 16^2 + 1 * 16^1 + 1 * 16^0 = 2816 + 16 + 1 = 2833

    在hexa中,10、11、12、13、14、15等数字用字母表示,如a、b、c、d、e、f

    查看here 了解更多信息。

    【讨论】:

      猜你喜欢
      • 2013-12-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多