Hey, I've been working on a project and seem to have hit a speedbump. I have been trying to find a way to calculate the time that a touch has been held(from time began to time release). I've been through timers and nothing seems to be working. I keep getting errors or no errors at all but the app crashes as soon as a touch occurs.
Any help would be appreciated
Touch Held
(3 posts) (2 voices)-
Posted 11 months ago #
-
// Needed vars (ivars or globals)
CFTimeInterval _startTime, _endTime;In your ccTouchesBegan have this to save current touch time.
_startTime = CACurrentMediaTime();In your ccTouchesEnded, get the endtime and calculate the difference in secs.
_endTime = CACurrentMediaTime(); float diff = _endTime - _startTime; NSLog(@"Time took: %f", diff);Posted 11 months ago # -
Thanks! I've been looking for the right function to find the time and that worked perfectly
Posted 11 months ago #
Reply
You must log in to post.