[SOLVED] Can someone please point out what i did wrong in my code for detecting collision in cocos2dx?

The fact is that it does not have to be a power of 2 - in fact it can be useful if it is not - for example I might want to differentiate between platform and wall, but my ‘roof’ needs to act like either.

In that case, wall = 0x08, platform = 0x10 and roof = 0x18 - so anything that collides with the wall or the platform will also collide with the roof.

In this use-case you need to use OR rather than PLUS.

As OR always works and PLUS only works in special cases, one should really use OR all the time.

Also just a small correction - it’s not 8 bit - and if it were and you limited yourself to 1 bit per item, there would only be 8 possibilities! It is 32 bit hence 32 individual possibilities.

ok, let me check by some demo.
I had use in many games but never had any problem.
Also it will be great if any cocos developer give advice here.

No, i didn’t mean that. You can see my above post, how i declare all mask.