The Box2D Blank Game
Game Physics with a 2D Physics Engine
Loading...
Searching...
No Matches
CMyListener Class Reference

My contact listener.

#include <ContactListener.h>

Inheritance diagram for CMyListener:
Collaboration diagram for CMyListener:

Public Member Functions

void PreSolve (b2Contact *, const b2Manifold *)
 Presolve function.
 

Private Member Functions

const UINT Count (eSprite) const
 Count number of bodies that have sprite type t.
 
const float GetSpeed (const b2Vec2 &) const
 Get the collision speed.
 

Private Attributes

b2Body * m_pBodyA = nullptr
 Pointer to body A.
 
b2Body * m_pBodyB = nullptr
 Pointer to body B.
 

Additional Inherited Members

- Static Protected Attributes inherited from CCommon
static CBox2DRenderer * m_pRenderer = nullptr
 Pointer to the Renderer.
 
static Sage::CParticleEngine2D * m_pParticleEngine = nullptr
 Pointer to particle engine.
 
static b2World * m_pPhysicsWorld = nullptr
 Pointer to Box2D Physics World.
 
static CObjectManagerm_pObjectManager = nullptr
 Pointer to the Object Manager.
 
static eDrawMode m_eDrawMode = eDrawMode::Sprites
 Draw mode.
 

Member Function Documentation

◆ Count()

const UINT CMyListener::Count ( eSprite t) const
private

Count the number of bodies out of *m_pBodyA and *m_pBodyB that have objects have a given sprite type. Returns 0, 1, or 2, of course.

Parameters
tSprite Type.
Returns
Number of *m_pBodyA and *m_pBodyB that have type t.
Here is the call graph for this function:

◆ GetSpeed()

const float CMyListener::GetSpeed ( const b2Vec2 & p) const
private

Get the collision speed, which is proportional to the magnitude of the relative velocity of the two bodies colliding.

Parameters
pWorld point, required by Box2D for some arcane reason.
Returns
Collision speed in Physics World units.
Here is the caller graph for this function:

◆ PreSolve()

void CMyListener::PreSolve ( b2Contact * c,
const b2Manifold * m )

Presolve function. Renders a colored star at each contact point and plays the appropriate sound, depending on what type of objects are contacting.

Parameters
cPointer to the contact.
mPointer to the old contact manifold as it was before this contact.
Here is the call graph for this function: