Hey guys.
I need help in detecting if a single touch is being held down.
I just want to do a simple test (for now, moving a sprite down) when they are touching the screen.
Here is my code so far.
- (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint point = [touch locationInView:[touch view]];
point = [[CCDirector sharedDirector] convertToGL:point];
//Not needed, but I added these for ease of coding.
int xcord = (point.x);
int ycord = (point.y);
if((xcord>=78)&&(xcord<=124)&&(ycord>=4)&&(ycord<=54)){
[self performSelector:@selector(moveplayerDown:) withObject:nil afterDelay:0.0];
//[self schedule: @selector(moveplayerDown:) interval:0.4];
}
So you can see I tried having it with an interval, but the player just kept moving even when I stopped touching. And the current performSelector does the move once and that's it.
Any opinions?