I have the following code to detect touches, and it works fine. However once I do an Action MoveTo, and I move the sprite to a new location the original location is the only region where the touch detection works, the new location of the sprite is not working properly, anyone know why?
-(BOOL)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint point = [touch locationInView: [touch view]];
point = [[Director sharedDirector] convertCoordinate: point];
CGRect rect = [mySprite rect];
if(CGRectContainsPoint(rect, point))
{
mySpriteClicked = YES;
}
return kEventHandled;
}
And then the Sprite object has the following:
- (CGRect) rect {
float w = [self contentSize].width;
float h = [self contentSize].height;
CGPoint point = CGPointMake([self position].x - (w/2), [self position].y - (h/2));
return CGRectMake(point.x, point.y, w, h);
}
If anyone could be of assistance it would be great, thanks!