- (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
location = [touch locationInView:[touch view]];
location = [[CCDirector sharedDirector] convertToGL:location];
//Here urSprite is your CCSprite which you want to move
CGRect urSpriteRect = CGRectMake([urSprite position].x - [urSprite contentSize].width/2,
[urSprite position].y - [urSprite contentSize].height/2,
[urSprite contentSize].height, [urSprite contentSize].width);
if (CGRectContainsPoint(urSpriteRect, location))
{
checkFlag = TRUE;
NSLog(@"You Touched the sprite!");
}
}
- (void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
if(checkFlag){
urSprite.position = location;
NSLog(@"You are moving your sprite!");
}
}
- (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
checkFlag = FALSE;
NSLog(@"Sprite stopped!");
}