本文介绍了Sprite Kit中允许的categoryBitMask的最大数量是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我听说每个Sprite Kit游戏只允许使用32种不同的categorybitmask。有没有办法解决?我绝对需要更多(自游戏开放世界以来大约3-4倍)。我将categorybitmask设置如下:

I heard only 32 different categorybitmask's are allowed to be used per Sprite Kit game. Is there any way around this? I absolutely need more then that (roughly 3-4 times more since the game is an open world one). I set up my categorybitmask's as following:

static const uint64_t boundaryCategory    = 0x1 << 0;
static const uint64_t mainCharCategory    = 0x1 << 1;
...
static const uint64_t someOtherCategory   = 0x1 << 31;

我甚至将uint32_t更改为uint64_t,希望这会使我可以使用的categorybitmask数量增加一倍。不幸的是,事实并非如此。如果有人知道绕过这个限制的任何技术,我将非常感激。

I even changed uint32_t to uint64_t hoping that would double the amount of categorybitmask's I could use. Unfortunately, it doesn't. If anyone knows any techniques to by-pass this limit, I will be very grateful.

推荐答案

你有多种方法可以可以在这个问题上发挥创意。例如,您可以使用节点的name属性。将所有敌人置于一个categoryBitMask下,并在联系完成后使用他们的名字来区分他们。

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.

另一种方法是使用SKNode字典属性。如果需要,这允许您存储更多详细数据,而不仅仅是字符串。

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

创建SKNode字典:

Creating a SKNode dictionary:

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

阅读字典:

NSString *myString = [myNode.userData objectForKey:@"enemyType"];

这篇关于Sprite Kit中允许的categoryBitMask的最大数量是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 01:02