What is the maximum number of categoryBitMask's allowed in Sprite Kit?

拥有回忆 提交于 2019-12-05 12:57:41

There are a number of ways you can get creative regarding this issue. You can, for example, use the name property of a node. Have all your enemies under one categoryBitMask and use their names to differentiate them once contact is made.

Another alternative is to use the SKNode dictionary property. This allows you to store more detailed data, if required, than just a string.

Creating a SKNode dictionary:

myNode.userData = [NSMutableDictionary dictionary];
[myNode.userData setObject:@"goblin" forKey:@"enemyType"];

Reading the dictionary:

NSString *myString = [myNode.userData objectForKey:@"enemyType"];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!