首先,我将包含精灵的图层缩放得更大。现在我需要感知精灵的触摸。我已经尝试如下,但无法达到目标 -
CGRect tRect= [[aSprite displayedFrame] rect];
if(CGRectContainsPoint(tRect, touchedPosition))
{
NSLog(@"touched:>> touch at (%f,%f)",touchedPosition.x,touchedPosition.y);
// Do something, maybe return kEventHandled;
}
else{
NSLog(@"NOT touched: touch at (%f,%f)",touchedPosition.x,touchedPosition.y);
}
仅供参考:我使用过 cocos2d 框架