cocos2dx hittest

bool Widget::hitTest(const CCPoint &pt)
{
	std::string disp = getDescription();

    CCPoint nsp = convertToNodeSpace(pt);

    CCRect bb = CCRect(-_size.width * m_obAnchorPoint.x, -_size.height * m_obAnchorPoint.y, _size.width, _size.height);

	if(disp.compare("CustomButton") == 0) 
	{
		bb = CCRect(0,0, _size.width, _size.height);
	}
    if (nsp.x >= bb.origin.x && nsp.x <= bb.origin.x + bb.size.width && nsp.y >= bb.origin.y && nsp.y <= bb.origin.y + bb.size.height)
    {
        return true;
    }
    return false;
}



你可能感兴趣的:(cocos2dx hittest)