#include "MathUtil.h" #include "ccMacros.h" NS_CC_MATH_BEGIN void MathUtil::smooth(float* x, float target, float elapsedTime, float responseTime) { GP_ASSERT(x); if (elapsedTime > 0) { *x += (target - *x) * elapsedTime / (elapsedTime + responseTime); } } void MathUtil::smooth(float* x, float target, float elapsedTime, float riseTime, float fallTime) { GP_ASSERT(x); if (elapsedTime > 0) { float delta = target - *x; *x += delta * elapsedTime / (elapsedTime + (delta > 0 ? riseTime : fallTime)); } } NS_CC_MATH_END