bool ManorBuilding::onTouchBegan(Touch *touch, Event event){
auto target = static_cast<Sprite>(event->getCurrentTarget());
//把世界坐标转换成本地坐标
Point locationInNode = target->convertTouchToNodeSpace(touch);
Size size = this->getTouchableSize();
//设置可点击域
Rect rect = Rect(0,0,size.width,size.height);
if (rect.containsPoint(locationInNode))
{
return true;
}
return false;
}
这个是在精灵区域就可以拖动,如果要实现单击及长按才返回true 类似coc塔防建筑移动