i've been searching easy way time step between touchedmoved method calls in cocos2d-x, far find nothing.. me out here?
you can accomplish directly c++ primitives, follow link:
http://www.cplusplus.com/reference/ctime/time/
you'll find sample script demonstrates how calculate difference between 2 times.
another way sum delta time of update method instance var, this:
void yourclass::update(float dt) { m_timer += dt; } then in ontouchbegin, ontouchmoved , ontouchended methods value of m_timer , count difference. example:
void yourclass::ontouchbegin(cocos2d::touch *touch, cocos2d::event *event) { float m_begintime = m_timer; } void yourclass::ontouchended(cocos2d::touch *touch, cocos2d::event *event) { float m_endtime = m_timer; float time_diff = m_endtime - m_begintime; }
Comments
Post a Comment