ios - Sprite Kit 中的物理类别结构

标签 ios swift uint32

我一直在使用 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 等是什么意思,以及如何在这里创建一个新常量?

最佳答案

是hexa,也就是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了解更多信息。

关于ios - Sprite Kit 中的物理类别结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31011788/

相关文章:

c++ - 在 C++ 中将位序列转换为 uint32_t

ios - iOS 8 中没有取消 UISlider 事件?

ios - Swift 函数式编程 - 有没有比两个 map 调用更好的方法来翻译嵌套的 for 循环

ios - 每个 CollectionView Cell 都有独特的计时器

swift - 我可以在 Swift 中声明函数然后定义它们的实现吗?

iphone - 使用构造方法创建一个http body

c - 编译为 cortex-m0 时,unsigned int 不是 uint32_t——可能是 C 编译器标志问题

ios - 临时安装 ios 失败 | 0x243000 verify_signer_identity

iphone - gpus_ReturnGuiltyForHardwareRestart 崩溃

arrays - 从 SwiftUI 中的列表中删除绑定(bind)