cocos js 模拟触摸事件

            var id = 0;
            var x = 530;
            var y = 225;
            var touch = new cc.Touch();
            touch.setTouchInfo(id, x, y);

            var event1 = new cc.EventTouch();
            event1.setEventCode(cc.EventTouch.EventCode.BEGAN);
            event1.setTouches([touch]);
            cc.eventManager.dispatchEvent(event1);

            var event2 = new cc.EventTouch();
            event2.setEventCode(cc.EventTouch.EventCode.ENDED);
            event2.setTouches([touch]);
            cc.eventManager.dispatchEvent(event2);

你可能感兴趣的:(cocos js 模拟触摸事件)