// sorry i don't know how put codes correctly in this place
hello,
i'm using TSprite code : http://lethain.com/entry/2008/oct/20/touch-detection-in-cocos2d-iphone/
///
-(void) ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{//event that starts when a finger touchs the screen
UITouch *touch = [touches anyObject];
CGPoint tmpLoc = [touch locationInView: [touch view]];
CGPoint location = [[CCDirector sharedDirector] convertToGL:tmpLoc];
if([TSprite SomethingWasTouched:location])
{
NSArray * mySprites = [TSprite allMySprites];
NSUInteger i, count = [mySprites count];
for (i = 0; i < count; i++)
{
TSprite * obj = (TSprite *)[mySprites objectAtIndex:i];
//-----------------------------------------------------------------------------/
//-----------------------------------------------------------------------------/
// this sprite is touched
if (CGRectContainsPoint([obj rect], location) && [obj GetCanTrack])
{
j = j+ 1 ; // j is a global var just to see how many times this condition is checked as YES for one touch
NSLog(@"Touched = %i", j);
}
//-----------------------------------------------------------------------------/
//-----------------------------------------------------------------------------/
else
// this sprite is not touched
{
}
//-----------------------------------------------------------------------------/
//-----------------------------------------------------------------------------/
}
}
}
///
i wonder why ??!!
thank you for your help
:=)