Hello all,
I have a couple of questions.
1. Do you think this is an adequate way of calculating velocity?
-(BOOL)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
LocationWhenTouchMoved = [[Director sharedDirector] convertCoordinate: [touch locationInView: [touch view]]];
TimeWhenTouchMoved = frames;
CGFloat deltaY = fabsf(LocationWhenTouchMoved.y - LocationWhenTouchBegan.y);
if (deltaY >= kMimimunGestureLength) {
float temporary = fabsf(LocationWhenTouchMoved.y - LocationWhenTouchBegan.y):
velocity = (float) temporary / (TimeWhenTouchMoved - TimeWhenTouchBegan);
}
I think that works fine, but there's one problem.
2. How can I calculate velocity so that it isn't dependent on TimeWhenTouchBegan? Because if the player first puts her finger on the screen and waits a while, velocity will be slow even though she moves her finger fast. It should be dependent on the first move instead, but I don't know how to achieve that.
Cheers!
