cc.Touch 事件调用 getLocationInView 报 height 属性不存在

  • Creator 版本:1.9.0

  • 目标平台: 模拟器

  • 详细报错信息,包含调用堆栈:
    Simulator: E/jswrapper (267): ERROR: Uncaught TypeError: Cannot read property ‘height’ of undefined, location: src/jsb_polyfill.js:0:0
    Simulator: STACK:
    Simulator: [0]74.proto.getLocationInView@src/jsb_polyfill.js:10700
    Simulator: [1]Dungeon.onTouchEnd@assets/Script/Logic/Scene/Map/Dungeon.js:71
    Simulator: [2]76.EventListeners.invoke@src/jsb_polyfill.js:10859
    Simulator: [3]_doDispatchEvent@src/jsb_polyfill.js:10905
    Simulator: [4]77.proto.dispatchEvent@src/jsb_polyfill.js:11022
    Simulator: [5]_mouseUpHandler@src/jsb_polyfill.js:2249
    Simulator: E/jswrapper (519): [ERROR] (…\jswrapper\v8\Object.cpp, 519): Invoking function (0617A780) failed!
    Simulator: jsb: ERROR: File …\manual\jsb_cocos2dx_manual.cpp: Line: 355, Function: invokeJSMouseCallback
    Simulator: invokeJSMouseCallback call function failed!

  • 重现方式:直接调用。

  • 之前哪个版本是正常的 :

  • 手机型号 :

  • 手机浏览器 :

  • 编辑器操作系统 :

  • 编辑器之前是否有其它报错 :

  • 出现概率:100%

  • 额外线索:

cc.Touch.prototype.getLocationInView = function() {
    return cc.v2(this._point.x, cc.view.getDesignResolutionSize().height - this._point.y);
}

可以尝试一下这段修复代码