Hi guys,

I’m using fixed step in my game and I thought it could be useful to someone trying to

achieve the same:

- Add this variable to your CCDirector.h

`float m_FixedTimeStepAccumulator;`

- Initialize de variable in the init method of CCDirector.cpp

`m_FixedTimeStepAccumulator = 0.0f;`

- Add this code to the drawScene method of CCDirector.cpp

@ //tick before glClear: issue #533@

@ if ( !m_bPaused )@

@ {@

@ // Fixed step implementation@

@ static const float FIXED_TIMESTEP = 1.0f / 60.f;@

@ static const int MAX_STEPS = 2;@

@

@ m_FixedTimeStepAccumulator += m_fDeltaTime;@

@ const int iSteps = static_cast(@

@ floorf( m_FixedTimeStepAccumulator / FIXED_TIMESTEP ) );@

@

@ // m_FixedTimeStepAccumulator will save the remaining time@

@ if ( iSteps > 0 )@

@ {@

@ m_FixedTimeStepAccumulator -= iSteps * FIXED_TIMESTEP;@

@ }@

@

@ CCAssert( m_FixedTimeStepAccumulator < FIXED_TIMESTEP + FLT_EPSILON,@

@ “Accumulator must have a value lesser than the fixed time step” );@

@

@ const int iStepsClamped = std::min( iSteps, MAX_STEPS );@

@ for ( int i = 0; i < iStepsClamped; ++i )@

@ {@

@ m_pScheduler->update( FIXED_TIMESTEP );@

@ }@

@ }@

Cheers!