Sprite Kit 中的物理类别结构
Physics category struct in Sprite Kit
我一直在使用 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 等是什么意思,以及如何在这里创建一个新常量?
是六进制,即16进制数
六进制中的 0b11 是
0 * 16^3 + 11 * 16^2 + 1 * 16^1 + 1 * 16^0 = 2816 + 16 + 1 = 2833
十六进制中,10、11、12、13、14、15等数字用字母a、b、c、d、e、f等表示
查看 here 了解更多信息。
我一直在使用 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 等是什么意思,以及如何在这里创建一个新常量?
是六进制,即16进制数
六进制中的 0b11 是
0 * 16^3 + 11 * 16^2 + 1 * 16^1 + 1 * 16^0 = 2816 + 16 + 1 = 2833
十六进制中,10、11、12、13、14、15等数字用字母a、b、c、d、e、f等表示
查看 here 了解更多信息。