cocos2d lua 判断触摸是否在某个区域内

首先转换坐标点为这个点的节点坐标

        local point = self.draw_bg:convertToNodeSpace(cc.p(touch:getLocation().x, touch:getLocation().y))

其次判断是否在这个区域内

local rect = cc.rect(0, 0, self.draw_bg:getContentSize().width, self.draw_bg:getContentSize().height)
        if cc.rectContainsPoint(rect, cc.p(point.x, point.y)) then
            return true
        end

猜你喜欢

转载自blog.csdn.net/ding_westbrook/article/details/80022976
今日推荐