我之前花了很多时间使用 cocos2d,并习惯了标签的便利性,这些标签也可以在 UIView 对象上使用,但目前我使用 spritekit 启动了一个项目,但找不到等效的项目。因此我的问题是,有谁知道 SKSpriteNode/SKNode 对象是否有任何与其等效的东西?
雪碧得到了更好的东西。在 SKNode 中,您可以设置整个字典,而不仅仅是一个标签。向你的新朋友问好.userData?
例子:
let myNode : SKSpriteNode = SKSpriteNode(imageNamed: "make-america-great-again")
myNode.userData = [
"keyA" : "blahblah",
"keyB" : 17.0
];
NSLog("OMFG is this \(myNode.userData?["keyA"]) and \(myNode.userData?["keyB"]) for real!??")
Run Code Online (Sandbox Code Playgroud)