判断触摸点 cocos2d-js

来源:互联网 发布:育知同创韩茹java 编辑:程序博客网 时间:2024/06/05 11:02
isTouchMe: function (target, touch, event, deltaSize, rect) {            deltaSize = deltaSize || cc.size(0, 0);            //Get the position of the current point relative to the button            var locationInNode = target.convertToNodeSpace(touch.getLocation());            var s = target.getContentSize();            var rect = rect || cc.rect(-deltaSize.width / 2, -deltaSize.height / 2, s.width + deltaSize.width, s.height + deltaSize.height);            //Check the click area            if (cc.rectContainsPoint(rect, locationInNode)) {                var flag = true;                var t = target;                while (true) {                    if (t == null)                        break;                    if (!t.isVisible() || t.getOpacity() == 0) {                        flag = false;                        break;                    }                    t = t.getParent();                }                return !!flag;            }            return false;        },

原创粉丝点击