【发布时间】:2013-01-29 12:43:46
【问题描述】:
在上图中,黄色代表一个大于 iPad 分辨率的精灵。我想在此处以白色表示的特定位置允许拖放功能。
我拥有的是: - CCActor 继承 CCSprite -targetedBoundingBox是根据精灵的白色圆圈的boundingBox。
我想要的: 如何根据精灵而不是屏幕获取touchLocation?
我的代码:
-(BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event {
CGPoint touchLocation = [self convertTouchToNodeSpace:touch];
CCActor * newSprite = [self selectSpriteForTouch:touchLocation];
if(newSprite != NULL){
//touchLocation should be according to the sprite.
if (CGRectContainsPoint(newSprite.targetedBoundingBox, touchLocation)) {
[self spriteSelected:newSprite];
return YES;
}
return NO;
}
return NO;
}
【问题讨论】:
标签: ios objective-c cocos2d-iphone