Having a problem with collision layers?

BlitzMax Forums/BlitzMax Programming/Having a problem with collision layers?

GfK(Posted 2008) [#1]
<stupid mode>

I was. I've never needed to use multiple ones before.

Anyway, I added a new layer last night and was getting stuff highlighting when it shouldn't be. After 45 minutes of fannying about and getting different but still wrong results, I noticed something interesting.

I was using constants for my layers and assigning values of 1, 2, 3, 4, 5 and so on. I didn't realise at the time but by using a value of 3, I was actually adding stuff to collision layer 1 *and* layer 2.

They're actually referenced by values 1, 2, 4, 8, 16... and so on.

I now realise that its been done this way so you can check for collisions on multiple layers at once, but it confused the hell out of me for a while.

</stupid mode>


Yan(Posted 2008) [#2]
I was using constants for my layers...

You know that COLLISION_LAYER_ALL and COLLISION_LAYER_1 -> COLLISION_LAYER_32 are already defined, yes?


GfK(Posted 2008) [#3]
I did, but didn't know what the actual values were until I checked last night.

However, its much clearer (to me, at least) having them called LAYER_GUI, LAYER_TILES etc. That way I know what's being put onto which layer just by looking at the code.