views:

33

answers:

0

I usd the CCBitmapFontAtlas to display a string and it works fine:

label = [CCBitmapFontAtlas bitmapFontAtlasWithString:@"RBT" fntFile:@"bitmapFontTest.fnt"];
    [self addChild:label];

    CGSize s = [[CCDirector sharedDirector] winSize];

    label.position = ccp(s.width/2, s.height/2);
    label.anchorPoint = ccp(0.5f, 0.5f);

Now I want to make some actions happen one of the letter while it is touched (say letter "R"), and here is what I tried:

CCSprite *RChar = (CCSprite*) [label getChildByTag:0];

CGSize s = [RChar.texture]; CGRect charRect = CGRectMake(-s.width / 2, -s.height / 2, s.width, s.height); NSLog(@"%0.1f, %0.1f, %0.1f, %0.1f", -s.width / 2,-s.height / 2, s.width,s.height);

if(CGRectContainsPoint(charRect, [self convertTouchToNodeSpaceAR:touch])) { NSLog(@"YES"); }

This doesn't work, the charRect size is :-128.0, -256.0, 256.0, 512.0 And I also tried this:

CCSprite *RChar = (CCSprite*) [label getChildByTag:0];
if(CGRectContainsPoint(RChar.textureRect, touchPoint)) {
NSLog(@"YES");

}

Doesn't work too.

Any advice will be appreciate ^_^