Game Development Reference
In-Depth Information
-(BOOL) ccTouchBegan:(UITouch*)touch withEvent:(UIEvent*)event
{
BOOL touchHandled = NO;
CGPoint location = [Helper locationFromTouch:touch];
if ([self isTouchForMe:location])
{
touchHandled = YES;
[self reverseMotor];
}
return touchHandled;
}
-(void) ccTouchEnded:(UITouch*)touch withEvent:(UIEvent*)event
{
CGPoint location = [Helper locationFromTouch:touch];
if ([self isTouchForMe:location])
{
[self reverseMotor];
}
}
The isTouchForMe method implements the check to figure out on which side of the
screen the touch was and whether the current instance of the class is the correct flipper
to respond to this touch.
-(bool) isTouchForMe:(CGPoint)location
{
if (type == kFlipperLeft && location.x < [Helper screenCenter].x)
{
return YES;
}
else if (type == kFlipperRight && location.x > [Helper screenCenter].x)
{
return YES;
}
return NO;
}
Search Nedrilad ::




Custom Search