//取得 CCSprite 寬跟高
CCSprite *sp = [CCSprite spriteWithFile:@"Icon.png"];
NSLog(@"sp width:%f,heigt,:%f",sp.contentSize.width , sp.contentSize.height);
//int 記錄與取得myArray = [NSMutableArray array];
[myArray addObject:[NSNumber numberWithInteger:1234]];
//..
int theNumber = [[myArray objectAtIndex:0] integerValue];//CGPoint記錄與取得
NSArray *points = [NSArray arrayWithObjects:
[NSValue valueWithCGPoint:CGPointMake(5.5, 6.6)],
[NSValue valueWithCGPoint:CGPointMake(7.7, 8.8)], nil];
NSValue *val = [points objectAtIndex:0];
CGPoint p = [val CGPointValue];
id path = @"https://www.google.com/images/logos/ps_logo2.png";
NSURL *url = [NSURL URLWithString:path];
NSData *data = [NSData dataWithContentsOfURL:url];
// UIImage *img = [[UIImage alloc] initWithData:data cache:NO];
UIImage *img =[ UIImage imageWithData:data];
UIImageView *imView = [[UIImageView alloc] initWithImage:img];
[self.view addSubview:imView ];
id path = @"https://www.google.com/images/logos/ps_logo2.png";
NSURL *imgUrl = [NSURL URLWithString:path];
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:imgUrl]];
CCTexture2D *tt2d = [[CCTexture2D alloc] initWithImage:image];
CCSprite *sp = [CCSprite spriteWithTexture:tt2d];
[self addChild: sp];
- (void)ccTouchesBegan:(NSSet*)touches withEvent:(UIEvent*)event{
UITouch* touch = [touches anyObject];
//先取得touch 的坐標 CGPoint location = [touch locationInView:[touch view]];location = [[CCDirector sharedDirector] convertToGL:location];
//驗證坐標CCSprite *m_targetSprite = xxx; <==取得目標物件 if (CGRectContainsPoint(m_targetSprite.boundingBox, location)) {//touch.....}}附註: 有時CCLayer 的坐標也要考慮進去才行~~~