I did implement your code posted above.
///////////////////////method to return tilemap coordinate///////////////
-(CGPoint)coordinatesAtPosition:(CGPoint)point
{
return ccp((int)(point.x/(15)), (int)(10-point.y/(10)));
}
///////////////////////END OF method to return tilemap coordinate///////////////
///////////////////////touch event//////////////////
- (BOOL)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView: [touch view]];
CGPoint convertedPoint = [[Director sharedDirector] convertCoordinate:location];
CGPoint locationClicked = [self coordinatesAtPosition:ccp((int)convertedPoint.x,(int)convertedPoint.y)];
NSLog(@"CGPointX %.f",locationClicked.x);
NSLog(@"CGPointY %.f", locationClicked.y);
}
///////////////////////END OF touch event//////////////////
The output are weird:
when I touch at TileMap (0,0) - it will return :
CGPointX: 0
CGPointY: -21
when touch at Tilemap(0,1) - it will return:
CGPointX: 0
CGPointY: -16 //sometime it return -17, -16, -15 same as others output. So from here i can see that the code doesn't return a tile coordinate with specific tile grid (one tile touch in one box). I can touch anywhere inside the box and get the different output.
Is there any mistake I've made? How to return it same as what we click on the map :-(