The Cannon Lullaby Toy
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

float GetSpeed (const b2Vec2 &)
 Get the collision speed.
 
eSprite GetBellType ()
 Get a pointer to the bell object in a bell collision.
 
b2Body * GetBall ()
 Get a pointer to a ball's body in Physics World.
 

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 b2World * m_pPhysicsWorld = nullptr
 Pointer to Box2D Physics World.
 
static CBox2DRenderer * m_pRenderer = nullptr
 Pointer to Render World.
 
static CObjectManagerm_pObjectManager = nullptr
 Pointer to the Object Manager.
 
static Sage::CParticleEngine2D * m_pFrontParticleEngine = nullptr
 Pointer to front particle engine.

 
static Sage::CParticleEngine2D * m_pBackParticleEngine = nullptr
 Pointer to front particle engine.
 
static CCannonm_pCannon = nullptr
 Pointer to a cannon.
 
static Vector2 m_vBellPos [NUMBELLS] = {Vector2(0.0f)}
 Positions of bells.
 
static float m_fGravity = 20.0f
 Magnitude of gravity in Render World units.
 
static eDrawMode m_eDrawMode = eDrawMode::Sprites
 Draw mode.
 

Member Function Documentation

◆ GetBall()

b2Body * CMyListener::GetBall ( )
private

Get a pointer to the ball object if a ball is colliding with a bell.

Returns
Pointer to a ball if one is colliding with bell, else nullptr.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetBellType()

eSprite CMyListener::GetBellType ( )
private

Get the bell type if a bell has been hit.

Returns
Bell type hit, eSprite::None if there is none.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSpeed()

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

Collision speed is proportional to the magnitude of the relative velocity.

Parameters
pWorld point.
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: