-
Book Overview & Buying
-
Table Of Contents
Panda3D 1.6 Game Engine Beginner's Guide
By :
Using BitMasks is actually pretty easy. This example will show us how.
In the setupCollisions method of our Cycle class, add the following code right after the lines where we add our CollisionSpheres to the CollisionNode:
self.shieldCN.setIntoCollideMask(BitMask32.bit(3))
self.shieldCN.setFromCollideMask(BitMask32.bit(2))Save the file as CycleClass_02.py.
Modify WorldClass_01.py to import CycleClass_02.py instead of CycleClass_01.py. Then, save it as WorldClass_02.py and run it from the command prompt. Attempt to collide the two cycles together and we'll see them pass through each other, like in the following screenshot:

Our cycles don't collide anymore! That's because they are set to have different From and Into BitMasks. BitMask.bit creates a BitMask that has the indicated bit set to 1, and all other bits set to 0. The calls to setIntoCollideMask
and setFromCollideMask
apply the masks created by BitMask.bit to the CollisionNode...
Change the font size
Change margin width
Change background colour