9. cocos2dx 判断点是否在框内

1:Node的通用方法
if(pItem->boundingBox().containsPoint(point))
{
   //do sth
}


2:other way
CCPoint pos = this->getPosition();
CCSize size = this->getContentSize();
CCRect rect(pos.x, pos.y, size.width, size.height);

if( CCRect::CCRectContainsPoint(rect, point)  )
{
    //do sth
}

你可能感兴趣的:(C++)