If a notification(ie, a UIAlertView) appears while touching the screen (or home button is being pressed), ccTouchEnded
will be called in game layer, but at the touch will already have ended.
How can I determine when the touch ends?
Check out the apple reference for UIResponder:
You probably want
touchesEnded:withEvent:
Hope this helps :)
-Make your scene conforms to protocol CCTargetedTouchDelegate
-Add This line to init
of your scene:
[[[CCDirector sharedDirector] touchDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:NO];
-Implement these functions:
- (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event
{
return YES;
}
-(void)ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event
{
//here touch is ended
}
You should implement ccTouchesCancelled
. This will occur whenever a touch event is interrupted.
Just check how many touch objects you have.
if([touches count] == 0)
{
//NO TOUCHES
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.