Game Development Reference
In-Depth Information
collisonFilter.categoryBits = 0x0010; // category = Wall
collisonFilter.maskBits = 0x0001; // mask = Ball
left- > SetFilterData(collisonFilter);
right- > SetFilterData(collisonFilter);
You've enabled continuous physics for this project because the ball can move at high
speeds. Without continuous physics it's possible that the ball may penetrate or pass
through other objects, or leave the table entirely.
If you run the project now, you'll see . . . a pinball table. Great. But how do you know
that the collision shapes are properly placed and active?
Box2D Debug Drawing
This is where the GLESDebugDraw class defined in the GLES-Render files comes in
handy. It's also the reason why in Listing 13-7 you added all child objects using a neg-
ative z-order. Remember that any drawing done by OpenGL ES code in a node's draw
method is drawn at a z-order of 0. If you want the OpenGL ES drawings to actually be
drawn over other nodes, you need to give those nodes a negative z-order.
Have another look at the part of the initPhysics method of the PinballT-
ableLayer class that initializes the Box2D debug drawing:
debugDraw = new GLESDebugDraw(PTM_RATIO);
world- > SetDebugDraw(debugDraw);
uint32 flags = 0;
flags + = b2Draw::e_shapeBit;
flags + = b2Draw::e_jointBit;
// flags + = b2Draw::e_aabbBit;
// flags + = b2Draw::e_pairBit;
// flags + = b2Draw::e_centerOfMassBit;
debugDraw- > SetFlags(flags);
An instance of the GLESDebugDraw class is created, using the pixel-to-meter ratio
given by the PTM_RATIO macro, and then stored in the PinballTableLayer in-
Search Nedrilad ::

Custom Search