[0]Laya.stage.scrollRect移动屏幕时点击舞台显示对象点击坐标偏移



使用Laya.stage.scrollRect滚动屏幕
出现坐标偏移现象【字节平台】,本地显示正常
附件 DEMO中,运行字节平台,选择IPHONEX出现本问题
版本:laya2.12.2
QQ图片20220301210611.png


问题:Laya.stage.scrollRect滚动屏幕后,无法正常点击界面按钮
 
已邀请:

淘剑龙

赞同来自: 100分

window.ttMiniGame=function(e,t){"use strict";class i{static isLocalNativeFile(e){for(var t=0,i=l.nativefiles.length;t<i;t++)if(-1!=e.indexOf(l.nativefiles[t]))return!0;return!1}static isNetFile(e){return e&&(-1!=e.indexOf("http://";)||-1!=e.indexOf("https://";))&&l.window.tt.env&&-1==e.indexOf(l.window.tt.env.USER_DATA_PATH)}static getFileInfo(e){var t=e,a=i.fakeObj[t];return null==a?null:a}static read(e,a="utf8",n=null,s="",o=!1,r=""){var d;d=""==s||-1==s.indexOf("http://";)&&-1==s.indexOf("https://";)?e:i.getFileNativePath(e),d=t.URL.getAdptedFilePath(d),i.fs.readFile({filePath:d,encoding:a,success:function(e){null!=n&&n.runWith([0,e])},fail:function(e){e&&""!=s?i.downFiles(l.safeEncodeURI(s),a,n,s,o,r):null!=n&&n.runWith([1])}})}static isFile(e){let t;try{t=i.fs.statSync(e)}catch(e){return!1}return t.isFile()}static downFiles(e,t="utf8",a=null,n="",s=!1,o="",r=!0){i.down({url:e,success:function(l){200===l.statusCode?i.readFile(l.tempFilePath,t,a,n,s,o,r):403===l.statusCode?null!=a&&a.runWith([0,e]):null!=a&&a.runWith([1,l])},fail:function(e){null!=a&&a.runWith([1,e])}}).onProgressUpdate(function(e){null!=a&&a.runWith([2,e.progress])})}static readFile(e,a="utf8",n=null,s="",o=!1,r="",d=!0){e=t.URL.getAdptedFilePath(e),i.fs.readFile({filePath:e,encoding:a,success:function(t){-1==e.indexOf("http://";)&&-1==e.indexOf("https://";)||-1!=e.indexOf(l.window.tt.env.USER_DATA_PATH)?null!=n&&n.runWith([0,t]):l.AutoCacheDownFile||o?(null!=n&&n.runWith([0,t]),i.copyTOCache(e,s,null,a,d)):null!=n&&n.runWith([0,t])},fail:function(e){e&&null!=n&&n.runWith([1,e])}})}static downOtherFiles(e,t=null,a="",n=!1,s=!0){i.down({url:e,success:function(e){200===e.statusCode?(l.autoCacheFile||n)&&-1==a.indexOf(".php")?(null!=t&&t.runWith([0,e.tempFilePath]),i.copyTOCache(e.tempFilePath,a,null,"",s)):null!=t&&t.runWith([0,e.tempFilePath]):null!=t&&t.runWith([1,e])},fail:function(e){null!=t&&t.runWith([1,e])}})}static copyFile(e,t,a=null){i.fs.copyFile({srcPath:e,destPath:t,success:function(){a&&a.runWith(0)},fail:function(e){a&&a.runWith([1,e])}})}static downLoadFile(e,a="",n=null,s="utf8"){window.navigator.userAgent.indexOf("MiniGame")<0?t.Laya.loader.load(e,n):a==t.Loader.IMAGE||a==t.Loader.SOUND?i.downOtherFiles(e,n,e,!0,!1):i.downFiles(e,s,n,e,!0,a,!1)}static copyTOCache(e,a,n,s="",o=!0){var r=e.split("/"),d=r[r.length-1],u=a,c=i.getFileInfo(a),h=i.getFileNativePath(d);i.fakeObj[u]={md5:d,readyUrl:a,size:0,times:t.Browser.now(),encoding:s,tempFilePath:e};var f=l.sizeLimit,m=i.getCacheUseSize();c?c.readyUrl!=a?i.fs.getFileInfo({filePath:e,success:function(t){o&&m+4194304+t.size>=f&&(t.size>l.minClearSize&&(l.minClearSize=t.size),i.onClearCacheRes()),i.deleteFile(e,a,n,s,t.size)},fail:function(e){null!=n&&n.runWith([1,e])}}):null!=n&&n.runWith([0]):i.fs.getFileInfo({filePath:e,success:function(t){o&&m+4194304+t.size>=f&&(t.size>l.minClearSize&&(l.minClearSize=t.size),i.onClearCacheRes()),i.fs.copyFile({srcPath:e,destPath:h,success:function(e){i.onSaveFile(a,d,!0,s,n,t.size)},fail:function(e){null!=n&&n.runWith([1,e])}})},fail:function(e){null!=n&&n.runWith([1,e])}})}static onClearCacheRes(){var e=l.minClearSize,t=[];for(var a in i.filesListObj)"fileUsedSize"!=a&&t.push(i.filesListObj[a]);i.sortOn(t,"times",i.NUMERIC);for(var n=0,s=1,o=t.length;s<o;s++){var r=t[s];if(n>=e)break;n+=r.size,i.deleteFile("",r.readyUrl)}}static sortOn(e,t,a=0){return a==i.NUMERIC?e.sort(function(e,i){return e[t]-i[t]}):a==(i.NUMERIC|i.DESCENDING)?e.sort(function(e,i){return i[t]-e[t]}):e.sort(function(e,i){return e[t]-i[t]})}static getFileNativePath(e){return i.fileNativeDir+"/"+e}static deleteFile(e,t="",a=null,n="",s=0){var o=i.getFileInfo(t),r=i.getFileNativePath(o.md5);i.fs.unlink({filePath:r,success:function(o){if(""!=e){var r=i.getFileNativePath(e);i.fs.copyFile({srcPath:e,destPath:r,success:function(o){i.onSaveFile(t,e,!0,n,a,s)},fail:function(e){null!=a&&a.runWith([1,e])}})}else i.onSaveFile(t,e,!1,n,a,s)},fail:function(e){null!=a&&a.runWith([1,e])}})}static deleteAll(){var e=[];for(var t in i.filesListObj)"fileUsedSize"!=t&&e.push(i.filesListObj[t]);for(var a=1,n=e.length;a<n;a++){var s=e[a];i.deleteFile("",s.readyUrl)}i.filesListObj&&i.filesListObj.fileUsedSize&&(i.filesListObj.fileUsedSize=0),i.writeFilesList("",JSON.stringify({}),!1)}static onSaveFile(e,a,n=!0,s="",o=null,r=0){var l=e;if(null==i.filesListObj.fileUsedSize&&(i.filesListObj.fileUsedSize=0),n){var d=i.getFileNativePath(a);i.filesListObj[l]={md5:a,readyUrl:e,size:r,times:t.Browser.now(),encoding:s,tempFilePath:d},i.filesListObj.fileUsedSize=parseInt(i.filesListObj.fileUsedSize)+r,i.writeFilesList(l,JSON.stringify(i.filesListObj),!0),null!=o&&o.runWith([0])}else if(i.filesListObj[l]){var u=parseInt(i.filesListObj[l].size);i.filesListObj.fileUsedSize=parseInt(i.filesListObj.fileUsedSize)-u,i.fakeObj[l].md5==i.filesListObj[l].md5&&delete i.fakeObj[l],delete i.filesListObj[l],i.writeFilesList(l,JSON.stringify(i.filesListObj),!1),null!=o&&o.runWith([0])}}static writeFilesList(e,t,a){var n=i.fileNativeDir+"/"+i.fileListName;i.fs.writeFile({filePath:n,encoding:"utf8",data:t,success:function(e){},fail:function(e){}}),!l.isZiYu&&l.isPosMsgYu&&l.window.tt.postMessage({url:e,data:i.filesListObj[e],isLoad:"filenative",isAdd:a})}static getCacheUseSize(){return i.filesListObj&&i.filesListObj.fileUsedSize?i.filesListObj.fileUsedSize:0}static getCacheList(e,t){let a;try{a=i.fs.statSync(e)}catch(e){a=null}a?i.readSync(i.fileListName,"utf8",t):(i.fs.mkdirSync(e,!0),t&&t.runWith([1]))}static existDir(e,t){i.fs.mkdir({dirPath:e,success:function(e){null!=t&&t.runWith([0,{data:JSON.stringify({})}])},fail:function(e){-1!=e.errMsg.indexOf("file already exists")?i.readSync(i.fileListName,"utf8",t):null!=t&&t.runWith([1,e])}})}static readSync(e,t="utf8",a=null,n=""){var s,o=i.getFileNativePath(e);try{s=i.fs.readFileSync(o,t),null!=a&&a.runWith([0,{data:s}])}catch(e){null!=a&&a.runWith([1])}}static setNativeFileDir(e){i.fileNativeDir=l.window.tt.env.USER_DATA_PATH+e}}i.fs=window.tt.getFileSystemManager(),i.down=window.tt.downloadFile,i.filesListObj={},i.fakeObj={},i.fileListName="layaairfiles.txt",i.ziyuFileData={},i.ziyuFileTextureData={},i.loadPath="",i.DESCENDING=2,i.NUMERIC=16;class a extends t.SoundChannel{constructor(e,t){super(),this._audio=e,this._miniSound=t,this._onEnd=a.bindToThis(this.__onEnd,this),e.onEnded(this._onEnd)}static bindToThis(e,t){return e.bind(t)}__onEnd(){if(1==this.loops)return this.completeHandler&&(t.Laya.systemTimer.once(10,this,this.__runComplete,[this.completeHandler],!1),this.completeHandler=null),this.stop(),void this.event(t.Event.COMPLETE);this.loops>0&&this.loops--,this.startTime=0,this.play()}play(){this.isStopped=!1,t.SoundManager.addChannel(this),this._audio.play()}set startTime(e){this._audio&&(this._audio.startTime=e)}set autoplay(e){this._audio.autoplay=e}get autoplay(){return this._audio.autoplay}get position(){return this._audio?this._audio.currentTime:0}get duration(){return this._audio?this._audio.duration:0}stop(){this.isStopped=!0,t.SoundManager.removeChannel(this),this.completeHandler=null,this._audio&&(this._audio.stop(),this.loop||(this._audio.offEnded(null),this._miniSound.dispose(),this._audio=null,this._miniSound=null,this._onEnd=null))}pause(){this.isStopped=!0,this._audio.pause()}get loop(){return this._audio.loop}set loop(e){this._audio.loop=e}resume(){this._audio&&(this.isStopped=!1,t.SoundManager.addChannel(this),this._audio.play())}set volume(e){this._audio&&(this._audio.volume=e)}get volume(){return this._audio?this._audio.volume:1}}class n extends t.EventDispatcher{constructor(){super(),this.loaded=!1}static _createSound(){return n._id++,l.window.tt&&l.window.tt.createInnerAudioContext&&l.window.tt.createInnerAudioContext()}load(e){if(n._musicAudio||(n._musicAudio=n._createSound()),i.isLocalNativeFile(e)){if(-1!=e.indexOf("http://";)||-1!=e.indexOf("https://";))if(""!=i.loadPath)e=e.split(i.loadPath)[1];else{var a=""!=t.URL.rootPath?t.URL.rootPath:t.URL._basePath;""!=a&&(e=e.split(a)[1])}}else e=t.URL.formatURL(e);if(this.url=e,this.readyUrl=e,n._audioCache[this.readyUrl])this.event(t.Event.COMPLETE);else if(l.autoCacheFile&&i.getFileInfo(e))this.onDownLoadCallBack(e,0);else if(l.autoCacheFile)if(i.isLocalNativeFile(e)){var s=e;if(""!=(a=""!=t.URL.rootPath?t.URL.rootPath:t.URL._basePath)&&(e=e.split(a)[1]),e||(e=s),l.subNativeFiles&&0==l.subNativeheads.length)for(var o in l.subNativeFiles){var r=l.subNativeFiles[o];l.subNativeheads=l.subNativeheads.concat(r);for(var d=0;d<r.length;d++)l.subMaps[r[d]]=o+"/"+r[d]}if(l.subNativeFiles&&-1!=e.indexOf("/")){var u=e.split("/")[0]+"/";if(u&&-1!=l.subNativeheads.indexOf(u)){var c=l.subMaps[u];e=e.replace(u,c)}}this.onDownLoadCallBack(e,0)}else!i.isLocalNativeFile(e)&&-1==e.indexOf("http://";)&&-1==e.indexOf("https://";)||-1!=e.indexOf("http://usr/";)?this.onDownLoadCallBack(e,0):i.downOtherFiles(l.safeEncodeURI(e),t.Handler.create(this,this.onDownLoadCallBack,[e]),e);else this.onDownLoadCallBack(e,0)}onDownLoadCallBack(e,a,s=null){if(null!=this._sound)if(a)this.event(t.Event.ERROR);else{var o;if(l.autoCacheFile){if(s)o=s;else if(i.isLocalNativeFile(e)){var r=""!=t.URL.rootPath?t.URL.rootPath:t.URL._basePath,d=e;""==r||-1==e.indexOf("http://";)&&-1==e.indexOf("https://";)||(o=e.split(r)[1]),o||(o=d)}else{var u=i.getFileInfo(e);if(u&&u.md5){var c=u.md5;o=i.getFileNativePath(c)}else o=e}this.url!=t.SoundManager._bgMusic?(this._sound=n._createSound(),this._sound.src=this.url=o):(this._sound=n._musicAudio,this._sound.src=this.url=o)}else this.url!=t.SoundManager._bgMusic?(this._sound=n._createSound(),this._sound.src=e):(this._sound=n._musicAudio,this._sound.src=e);this._sound.onCanplay(n.bindToThis(this.onCanPlay,this)),this._sound.onError(n.bindToThis(this.onError,this))}}onError(e){try{console.log("-----1---------------minisound-----id:"+n._id),console.log(e)}catch(e){console.log("-----2---------------minisound-----id:"+n._id),console.log(e)}this.event(t.Event.ERROR),this._sound.offError(null)}onCanPlay(){this.loaded=!0,this.event(t.Event.COMPLETE),this._sound.offCanplay(null)}static bindToThis(e,t){return e.bind(t)}play(e=0,s=0){var o;if(this.url==t.SoundManager._bgMusic?(n._musicAudio||(n._musicAudio=n._createSound()),o=n._musicAudio):o=n._audioCache[this.readyUrl]?n._audioCache[this.readyUrl]._sound:n._createSound(),!o)return null;if(l.autoCacheFile&&i.getFileInfo(this.url)){var r=i.getFileInfo(this.url).md5;o.src=this.url=i.getFileNativePath(r)}else o.src=this.url;var d=new a(o,this);return d.url=this.url,d.loops=s,d.loop=0===s,d.startTime=e,d.play(),t.SoundManager.addChannel(d),d}get duration(){return this._sound.duration}dispose(){var e=n._audioCache[this.readyUrl];e&&(e.src="",e._sound&&(e._sound.destroy(),e._sound=null,e=null),delete n._audioCache[this.readyUrl]),this._sound&&(this._sound.destroy(),this._sound=null,this.readyUrl=this.url=null)}}n._id=0,n._audioCache={};class s{constructor(){}static _createInputElement(){t.Input._initInput(t.Input.area=t.Browser.createElement("textarea")),t.Input._initInput(t.Input.input=t.Browser.createElement("input")),t.Input.inputContainer=t.Browser.createElement("div"),t.Input.inputContainer.style.position="absolute",t.Input.inputContainer.style.zIndex=1e5,t.Browser.container.appendChild(t.Input.inputContainer),t.Laya.stage.on("resize",null,s._onStageResize),l.window.tt.onWindowResize&&l.window.tt.onWindowResize(function(e){}),t.SoundManager._soundClass=n,t.SoundManager._musicClass=n;var e=l.systemInfo.model,i=l.systemInfo.system;-1!=e.indexOf("iPhone")&&(t.Browser.onIPhone=!0,t.Browser.onIOS=!0,t.Browser.onIPad=!0,t.Browser.onAndroid=!1),-1==i.indexOf("Android")&&-1==i.indexOf("Adr")||(t.Browser.onAndroid=!0,t.Browser.onIPhone=!1,t.Browser.onIOS=!1,t.Browser.onIPad=!1)}static _onStageResize(){t.Laya.stage._canvasTransform.identity().scale(t.Browser.width/t.Render.canvas.width/t.Browser.pixelRatio,t.Browser.height/t.Render.canvas.height/t.Browser.pixelRatio)}static inputFocus(e){var i=t.Input.inputElement.target;i&&!i.editable||(l.window.tt.offKeyboardConfirm(),l.window.tt.offKeyboardInput(),l.window.tt.showKeyboard({defaultValue:i.text,maxLength:i.maxChars,multiple:i.multiline,confirmHold:!0,confirmType:i.confirmType||"done",success:function(e){},fail:function(e){}}),l.window.tt.onKeyboardConfirm(function(e){var a=e?e.value:"";i._restrictPattern&&(a=a.replace(/\u2006|\x27/g,""),i._restrictPattern.test(a)&&(a=a.replace(i._restrictPattern,""))),i.text=a,i.event(t.Event.INPUT),s.inputEnter(),i.event("confirm")}),l.window.tt.onKeyboardInput(function(e){var a=e?e.value:"";i.multiline||-1==a.indexOf("\n")?(i._restrictPattern&&(a=a.replace(/\u2006|\x27/g,""),i._restrictPattern.test(a)&&(a=a.replace(i._restrictPattern,""))),i.text=a,i.event(t.Event.INPUT)):s.inputEnter()}))}static inputEnter(){t.Input.inputElement.target.focus=!1}static inputblur(){s.hideKeyboard()}static hideKeyboard(){l.window.tt.offKeyboardConfirm(),l.window.tt.offKeyboardInput(),l.window.tt.hideKeyboard({success:function(e){console.log("隐藏键盘")},fail:function(e){console.log("隐藏键盘出错:"+(e?e.errMsg:""))}})}}class o extends t.EventDispatcher{constructor(){super()}_loadResourceFilter(e,a){if(this.sourceUrl=t.URL.formatURL(a),i.isNetFile(a))if(""!=i.loadPath)a=a.split(i.loadPath)[1];else{var n=""!=t.URL.rootPath?t.URL.rootPath:t.URL._basePath,s=a;""!=n&&(a=a.split(n)[1]),a||(a=s)}if(l.subNativeFiles&&0==l.subNativeheads.length)for(var r in l.subNativeFiles){var d=l.subNativeFiles[r];l.subNativeheads=l.subNativeheads.concat(d);for(var u=0;u<d.length;u++)l.subMaps[d[u]]=r+"/"+d[u]}if(l.subNativeFiles&&-1!=a.indexOf("/")){var c=a.split("/")[0]+"/";if(c&&-1!=l.subNativeheads.indexOf(c)){var h=l.subMaps[c];a=a.replace(c,h)}}switch(e){case t.Loader.IMAGE:case"htmlimage":case"nativeimage":o._transformImgUrl(a,e,this);break;case t.Loader.SOUND:this._loadSound(a);break;default:this._loadResource(e,a)}}_loadSound(e){if(l.autoCacheFile){var a=t.URL.formatURL(e);i.isLocalNativeFile(e)||i.getFileInfo(a)?o.onDownLoadCallBack(e,this,0):i.isNetFile(a)?i.downOtherFiles(l.safeEncodeURI(a),t.Handler.create(o,o.onDownLoadCallBack,[a,this]),a):o.onDownLoadCallBack(e,this,0)}else o.onDownLoadCallBack(e,this,0)}static onDownLoadCallBack(e,a,n,s=null){if(n)a.event(t.Event.ERROR,"Load sound failed");else{var o;if(l.autoCacheFile)if(s)o=s;else if(i.isLocalNativeFile(e))o=e;else{var r=i.getFileInfo(e);o=r&&r.md5?r.tempFilePath||i.getFileNativePath(r.md5):e}else o=t.URL.formatURL(e);e=o;var d=new t.SoundManager._soundClass;d.load(e),a.onLoaded(d)}}complete(e){e instanceof t.Resource?e._setCreateURL(this.sourceUrl):e instanceof t.Texture&&e.bitmap instanceof t.Resource&&e.bitmap._setCreateURL(this.sourceUrl),this.originComplete(e)}_loadHttpRequestWhat(e,a){var n=l.getUrlEncode(e,a);if(t.Loader.preLoadedMap[e])this.onLoaded(t.Loader.preLoadedMap[e]);else{var s=t.URL.formatURL(e);if(l.AutoCacheDownFile)if(i.isLocalNativeFile(e)||i.getFileInfo(s)){var r=e,d=i.getFileInfo(s);d&&d.md5&&(r=d.tempFilePath||i.getFileNativePath(d.md5)),i.readFile(r,n,new t.Handler(o,o.onReadNativeCallBack,[e,a,this]),e)}else i.isNetFile(s)?i.downFiles(l.safeEncodeURI(s),n,new t.Handler(o,o.onReadNativeCallBack,[e,a,this]),s,!0):i.readFile(e,n,new t.Handler(o,o.onReadNativeCallBack,[e,a,this]),e);else i.isNetFile(s)?this._loadHttpRequest(s,a,this,this.onLoaded,this,this.onProgress,this,this.onError):i.readFile(e,n,new t.Handler(o,o.onReadNativeCallBack,[e,a,this]),e)}}static onReadNativeCallBack(e,i=null,a=null,n=0,s=null){var o;n?1==n&&a._loadHttpRequest(e,i,a,a.onLoaded,a,a.onProgress,a,a.onError):(o=i==t.Loader.JSON||i==t.Loader.ATLAS||i==t.Loader.PREFAB||i==t.Loader.PLF?l.getJson(s.data):i==t.Loader.XML?t.Utils.parseXMLFromString(s.data):s.data,!l.isZiYu&&l.isPosMsgYu&&i!=t.Loader.BUFFER&&l.window.tt.postMessage({url:e,data:o,isLoad:"filedata"}),a.onLoaded(o))}static _transformImgUrl(e,a,n){if(l.isZiYu||i.isLocalNativeFile(e))n._loadImage(e,!1);else if(l.autoCacheFile){var s=t.URL.formatURL(e);i.isLocalNativeFile(e)||i.getFileInfo(s)?o.onCreateImage(e,n):i.isNetFile(s)?i.downOtherFiles(l.safeEncodeURI(s),new t.Handler(o,o.onDownImgCallBack,[e,n]),s):o.onCreateImage(e,n,!0)}else n._loadImage(l.safeEncodeURI(e))}static onDownImgCallBack(e,t,i,a=""){i?t.onError(null):o.onCreateImage(e,t,!1,a)}static onCreateImage(e,a,n=!1,s=""){var o;if(l.autoCacheFile)if(n)if(l.isZiYu){var r=t.URL.formatURL(e);o=i.ziyuFileTextureData[r]?i.ziyuFileTextureData[r]:e}else o=e;else if(""!=s)o=s;else{var d=i.getFileInfo(t.URL.formatURL(e));o=d.tempFilePath||i.getFileNativePath(d.md5)}else o=n?e:s;a._loadImage(o,!1)}}class r{constructor(){}static __init__(){r.items=r}static setItem(e,t){try{l.window.tt.setStorageSync(e,t)}catch(i){l.window.tt.setStorage({key:e,data:t})}}static getItem(e){return l.window.tt.getStorageSync(e)}static setJSON(e,t){r.setItem(e,t)}static getJSON(e){return r.getItem(e)}static removeItem(e){l.window.tt.removeStorageSync(e)}static clear(){l.window.tt.clearStorageSync()}static getStorageInfoSync(){try{var e=l.window.tt.getStorageInfoSync();return console.log(e.keys),console.log(e.currentSize),console.log(e.limitSize),e}catch(e){}return null}}r.support=!0;class l{static getJson(e){return JSON.parse(e)}static enable(){l.init(t.Laya.isWXPosMsg,t.Laya.isWXOpenDataContext)}static init(e=!1,a=!1){l._inited||(l._inited=!0,l.window=window,l.window.hasOwnProperty("tt")&&(l.window.navigator.userAgent.indexOf("MiniGame")<0||(l.isZiYu=a,l.isPosMsgYu=e,l.EnvConfig={},l.isZiYu||(i.setNativeFileDir("/layaairGame"),i.getCacheList(i.fileNativeDir,t.Handler.create(l,l.onMkdirCallBack))),l.systemInfo=l.window.tt.getSystemInfoSync(),l.window.focus=function(){},t.Laya._getUrlPath=function(){return""},l.window.logtime=function(e){},l.window.alertTimeLog=function(e){},l.window.resetShareInfo=function(){},l.window.CanvasRenderingContext2D=function(){},l.window.CanvasRenderingContext2D.prototype=l.window.tt.createCanvas().getContext("2d").__proto__,l.window.document.body.appendChild=function(){},t.HttpRequest._urlEncode=l.safeEncodeURI,l.EnvConfig.pixelRatioInt=0,t.Browser._pixelRatio=l.pixelRatio(),l._preCreateElement=t.Browser.createElement,t.Browser.createElement=l.createElement,t.RunDriver.createShaderCondition=l.createShaderCondition,t.Utils.parseXMLFromString=l.parseXMLFromString,t.Input._createInputElement=s._createInputElement,l.openCtx=l.window.tt.getOpenDataContext(),t.Loader.prototype._loadResourceFilter=o.prototype._loadResourceFilter,t.Loader.prototype.originComplete=t.Loader.prototype.complete,t.Loader.prototype.complete=o.prototype.complete,t.Loader.prototype._loadSound=o.prototype._loadSound,t.Loader.prototype._loadHttpRequestWhat=o.prototype._loadHttpRequestWhat,t.LocalStorage._baseClass=r,r.__init__(),l.window.tt.onMessage&&l.window.tt.onMessage(l._onMessage))))}static _onMessage(e){switch(e.type){case"changeMatrix":t.Laya.stage.transform.identity(),t.Laya.stage._width=e.w,t.Laya.stage._height=e.h,t.Laya.stage._canvasTransform=new t.Matrix(e.a,e.b,e.c,e.d,e.tx,e.ty);break;case"display":t.Laya.stage.frameRate=e.rate||t.Stage.FRAME_FAST;break;case"undisplay":t.Laya.stage.frameRate=t.Stage.FRAME_SLEEP}"opendatacontext"==e.isLoad?e.url&&(i.ziyuFileData[e.url]=e.atlasdata,i.ziyuFileTextureData[e.imgReadyUrl]=e.imgNativeUrl):"openJsondatacontext"==e.isLoad?e.url&&(i.ziyuFileData[e.url]=e.atlasdata):"openJsondatacontextPic"==e.isLoad&&(i.ziyuFileTextureData[e.imgReadyUrl]=e.imgNativeUrl)}static getUrlEncode(e,t){return"arraybuffer"==t?"":"utf8"}static downLoadFile(e,t="",a=null,n="utf8"){i.getFileInfo(e)?null!=a&&a.runWith([0]):i.downLoadFile(e,t,a,n)}static remove(e,t=null){i.deleteFile("",e,t,"",0)}static removeAll(){i.deleteAll()}static hasNativeFile(e){return i.isLocalNativeFile(e)}static getFileInfo(e){return i.getFileInfo(e)}static getFileList(){return i.filesListObj}static exitMiniProgram(){l.window.tt.exitMiniProgram()}static onMkdirCallBack(e,t){e?(i.fakeObj={},i.filesListObj={}):(i.filesListObj=JSON.parse(t.data),i.fakeObj=JSON.parse(t.data));let a=i.fs.readdirSync(i.fileNativeDir);if(a&&a.length){var n,s,o={};for(let e in i.filesListObj)"fileUsedSize"!=e&&(o[(n=i.filesListObj[e]).md5]=n.readyUrl);for(let e=0,t=a.length;e<t;e++)if((s=a[e])!=i.fileListName){if(!o[s]){let e=i.getFileNativePath(s);i.fs.unlink({filePath:e,success:function(e){console.log("删除无引用的磁盘文件:"+s)}})}delete o[s]}for(let e in o)delete i.filesListObj[o[e]],delete i.fakeObj[o[e]],console.log("删除错误记录:",o[e])}}static pixelRatio(){if(!l.EnvConfig.pixelRatioInt)try{return l.EnvConfig.pixelRatioInt=l.systemInfo.pixelRatio,l.systemInfo.pixelRatio}catch(e){}return l.EnvConfig.pixelRatioInt}static createElement(e){var t;if("canvas"==e)return 1==l.idx?l.isZiYu?(t=l.window.sharedCanvas).style={}:t=l.window.canvas:t=l.window.tt.createCanvas(),l.idx++,t;if("textarea"==e||"input"==e)return l.onCreateInput(e);if("div"==e){var i=l._preCreateElement(e);return i.contains=function(e){return null},i.removeChild=function(e){},i}return l._preCreateElement(e)}static onCreateInput(e){var t=l._preCreateElement(e);return t.focus=s.inputFocus,t.blur=s.inputblur,t.style={},t.value=0,t.parentElement={},t.placeholder={},t.type={},t.setColor=function(e){},t.setType=function(e){},t.setFontFace=function(e){},t.addEventListener=function(e){},t.contains=function(e){return null},t.removeChild=function(e){},t}static createShaderCondition(e){return function(){return this[e.replace("this.","")]}}static sendAtlasToOpenDataContext(e){if(!l.isZiYu){var i=t.Loader.getRes(t.URL.formatURL(e));if(!i)throw"传递的url没有获取到对应的图集数据信息,请确保图集已经过!";i.meta.image.split(",");if(i.meta&&i.meta.image)for(var a=i.meta.image.split(","),n=e.indexOf("/")>=0?"/":"\\",s=e.lastIndexOf(n),o=s>=0?e.substr(0,s+1):"",r=0,d=a.length;r<d;r++)a[r]=o+a[r];else a=[e.replace(".json",".png")];for(r=0;r<a.length;r++){var u=a[r];l.postInfoToContext(t.Laya.URL.formatURL(e),t.Laya.URL.formatURL(u),i)}}}static postInfoToContext(e,a,n){var s={frames:n.frames,meta:n.meta},o=a,r=i.getFileInfo(t.URL.formatURL(a));if(r)var d=r.tempFilePath||i.getFileNativePath(r.md5);else d=o;if(!d)throw"获取图集的磁盘url路径不存在!";l.openCtx.postMessage({url:e,atlasdata:s,imgNativeUrl:d,imgReadyUrl:o,isLoad:"opendatacontext"})}static sendSinglePicToOpenDataContext(e){var a=t.URL.formatURL(e),n=i.getFileInfo(a);if(n){var s=n.tempFilePath||i.getFileNativePath(n.md5);e=a}else s=e;if(!s)throw"获取图集的磁盘url路径不存在!";e=t.Laya.URL.formatURL(e),l.openCtx.postMessage({url:e,imgNativeUrl:s,imgReadyUrl:e,isLoad:"openJsondatacontextPic"})}static sendJsonDataToDataContext(e){if(!l.isZiYu){e=t.Laya.URL.formatURL(e);var i=t.Loader.getRes(e);if(!i)throw"传递的url没有获取到对应的图集数据信息,请确保图集已经过!";l.openCtx.postMessage({url:e,atlasdata:i,isLoad:"openJsondatacontext"})}}}l.IGNORE=new RegExp("[-_.!~*'();/?:@&=+$,#%]|[0-9|A-Z|a-z]"),l.safeEncodeURI=function(e){for(var t="",i=e.length,a=0;a<i;a++){var n=e[a];if(l.IGNORE.test(n))t+=n;else try{t+=encodeURI(n)}catch(e){console.log("errorInfo",">>>"+n)}}return t},l._inited=!1,l.autoCacheFile=!0,l.minClearSize=5242880,l.sizeLimit=52428800,l.nativefiles=["layaNativeDir","wxlocal"],l.subNativeFiles=[],l.subNativeheads=[],l.subMaps=[],l.AutoCacheDownFile=!1,l.parseXMLFromString=function(e){var t;e=e.replace(/>\s+</g,"><");try{t=(new l.window.Parser.DOMParser).parseFromString(e,"text/xml")}catch(e){throw"需要引入xml解析库文件"}return t},l.idx=1;class d extends t.EventDispatcher{constructor(){super()}static __init__(){try{var e;if(!(e=t.Accelerator))return;e.prototype.on=d.prototype.on,e.prototype.off=d.prototype.off}catch(e){}}static startListen(e){if(d._callBack=e,!d._isListening){d._isListening=!0;try{l.window.tt.onAccelerometerChange(d.onAccelerometerChange)}catch(e){}}}static stopListen(){d._isListening=!1;try{l.window.tt.stopAccelerometer({})}catch(e){}}static onAccelerometerChange(e){var t;(t={}).acceleration=e,t.accelerationIncludingGravity=e,t.rotationRate={},null!=d._callBack&&d._callBack(t)}on(e,t,i,a=null){return super.on(e,t,i,a),d.startListen(this.onDeviceOrientationChange),this}off(e,t,i,a=!1){return this.hasListener(e)||d.stopListen(),super.off(e,t,i,a)}}d._isListening=!1;class u{_loadImage(e){if(l.isZiYu)u.onCreateImage(e,this,!0);else{var a;if(i.isLocalNativeFile(e)){if(-1==e.indexOf(l.window.tt.env.USER_DATA_PATH)&&(-1!=e.indexOf("http://";)||-1!=e.indexOf("https://";)))if(""!=i.loadPath)e=e.split(i.loadPath)[1];else{var n=""!=t.URL.rootPath?t.URL.rootPath:t.URL._basePath,s=e;""!=n&&(e=e.split(n)[1]),e||(e=s)}if(l.subNativeFiles&&0==l.subNativeheads.length)for(var o in l.subNativeFiles){var r=l.subNativeFiles[o];l.subNativeheads=l.subNativeheads.concat(r);for(var d=0;d<r.length;d++)l.subMaps[r[d]]=o+"/"+r[d]}if(l.subNativeFiles&&-1!=e.indexOf("/")){var c=e.split("/")[0]+"/";if(c&&-1!=l.subNativeheads.indexOf(c)){var h=l.subMaps[c];e=e.replace(c,h)}}}else a=!0,e=t.URL.formatURL(e);i.getFileInfo(e)?u.onCreateImage(e,this,!a):-1!=e.indexOf(l.window.tt.env.USER_DATA_PATH)||-1==e.indexOf("http://";)&&-1==e.indexOf("https://";)?u.onCreateImage(e,this,!0):l.isZiYu?u.onCreateImage(e,this,!0):i.downOtherFiles(e,new t.Handler(u,u.onDownImgCallBack,[e,this]),e)}}static onDownImgCallBack(e,t,i,a=""){i?t.onError(null):u.onCreateImage(e,t,!1,a)}static onCreateImage(e,a,n=!1,s=""){var o,r;if(l.autoCacheFile)if(n)if(l.isZiYu){var d=t.URL.formatURL(e);o=i.ziyuFileTextureData[d]?i.ziyuFileTextureData[d]:e}else o=e;else if(""!=s)o=s;else{var u=i.getFileInfo(e).md5;o=i.getFileNativePath(u)}else o=n?e:s;function clear(){var e=a._imgCache[o];e&&(e.onload=null,e.onerror=null,delete a._imgCache[o])}null==a._imgCache&&(a._imgCache={});var c=function(){clear(),delete i.fakeObj[e],delete i.filesListObj[e],a.event(t.Event.ERROR,"Load image failed")};if("nativeimage"==a._type){var h=function(){clear(),a.onLoaded(r)};(r=new t.Browser.window.Image).crossOrigin="",r.onload=h,r.onerror=c,r.src=o,a._imgCache[o]=r}else{var f=new t.Browser.window.Image;h=function(){(r=t.HTMLImage.create(f.width,f.height)).loadImageSource(f,!0),r._setCreateURL(o),clear(),a.onLoaded(r)},f.crossOrigin="",f.onload=h,f.onerror=c,f.src=o,a._imgCache[o]=f}}}class c{constructor(){}static __init__(){l.window.navigator.geolocation.getCurrentPosition=c.getCurrentPosition,l.window.navigator.geolocation.watchPosition=c.watchPosition,l.window.navigator.geolocation.clearWatch=c.clearWatch}static getCurrentPosition(e=null,t=null,i=null){var a;(a={}).success=function(t){null!=e&&e(t)},a.fail=t,l.window.tt.getLocation(a)}static watchPosition(e=null,i=null,a=null){var n;return c._curID++,(n={}).success=e,n.error=i,c._watchDic[c._curID]=n,t.Laya.systemTimer.loop(1e3,null,c._myLoop),c._curID}static clearWatch(e){delete c._watchDic[e],c._hasWatch()||t.Laya.systemTimer.clear(null,c._myLoop)}static _hasWatch(){var e;for(e in c._watchDic)if(c._watchDic[e])return!0;return!1}static _myLoop(){c.getCurrentPosition(c._mySuccess,c._myError)}static _mySuccess(e){var i,a={};for(i in a.coords=e,a.timestamp=t.Browser.now(),c._watchDic)c._watchDic[i].success&&c._watchDic[i].success(a)}static _myError(e){var t;for(t in c._watchDic)c._watchDic[t].error&&c._watchDic[t].error(e)}}c._watchDic={},c._curID=0;e.MiniAccelerator=d,e.MiniFileMgr=i,e.MiniImage=u,e.MiniInput=s,e.MiniLoader=o,e.MiniLocalStorage=r,e.MiniLocation=c,e.MiniSound=n,e.MiniSoundChannel=a,e.MiniVideo=class{constructor(e=320,t=240){this.videoend=!1,this.videourl="",this.videoElement=l.window.tt.createVideo({width:e,height:t,autoplay:!0})}static __init__(){}on(e,t,i){"loadedmetadata"==e?(this.onPlayFunc=i.bind(t),this.videoElement.onPlay=this.onPlayFunction.bind(this)):"ended"==e&&(this.onEndedFunC=i.bind(t),this.videoElement.onEnded=this.onEndedFunction.bind(this)),this.videoElement.onTimeUpdate=this.onTimeUpdateFunc.bind(this)}onTimeUpdateFunc(e){this.position=e.position,this._duration=e.duration}get duration(){return this._duration}onPlayFunction(){this.videoElement&&(this.videoElement.readyState=200),console.log("=====视频加载完成========"),null!=this.onPlayFunc&&this.onPlayFunc()}onEndedFunction(){this.videoElement&&(this.videoend=!0,console.log("=====视频播放完毕========"),null!=this.onEndedFunC&&this.onEndedFunC())}off(e,t,i){"loadedmetadata"==e?(this.onPlayFunc=i.bind(t),this.videoElement.offPlay=this.onPlayFunction.bind(this)):"ended"==e&&(this.onEndedFunC=i.bind(t),this.videoElement.offEnded=this.onEndedFunction.bind(this))}load(e){this.videoElement&&(this.videoElement.src=e)}play(){this.videoElement&&(this.videoend=!1,this.videoElement.play())}pause(){this.videoElement&&(this.videoend=!0,this.videoElement.pause())}get currentTime(){return this.videoElement?this.videoElement.initialTime:0}set currentTime(e){this.videoElement&&(this.videoElement.initialTime=e)}get videoWidth(){return this.videoElement?this.videoElement.width:0}get videoHeight(){return this.videoElement?this.videoElement.height:0}get ended(){return this.videoend}get loop(){return!!this.videoElement&&this.videoElement.loop}set loop(e){this.videoElement&&(this.videoElement.loop=e)}get playbackRate(){return this.videoElement?this.videoElement.playbackRate:0}set playbackRate(e){this.videoElement&&(this.videoElement.playbackRate=e)}get muted(){return!!this.videoElement&&this.videoElement.muted}set muted(e){this.videoElement&&(this.videoElement.muted=e)}get paused(){return!!this.videoElement&&this.videoElement.paused}size(e,t){this.videoElement&&(this.videoElement.width=e,this.videoElement.height=t)}get x(){return this.videoElement?this.videoElement.x:0}set x(e){this.videoElement&&(this.videoElement.x=e)}get y(){return this.videoElement?this.videoElement.y:0}set y(e){this.videoElement&&(this.videoElement.y=e)}get currentSrc(){return this.videoElement.src}destroy(){this.videoElement&&this.videoElement.destroy(),this.videoElement=null,this.onEndedFunC=null,this.onPlayFunc=null,this.videoend=!1,this.videourl=null}reload(){this.videoElement&&(this.videoElement.src=this.videourl)}},e.TTMiniAdapter=l};

Yan

赞同来自:

您提供的这个示例下载后显示文件损坏,辛苦重新上传一个

Yan

赞同来自:

您好,我们在真机上测没有问题,iPhone X也没有问题。ide上偏移需要去问字节那面。

Yan

赞同来自:

将这句话注释掉试一下呢?只是注释掉后舞台不在移动,小球移动。是否与您的需求不同?

淘剑龙

赞同来自:

已找到问题所在!

100分

赞同来自:

请问您是如何解决的?我这里也遇到了类似的

淘剑龙

赞同来自:

 
终极原因找到了,框里执行顺序反了,导致的问题。。。。。绝对的官方BUG

淘剑龙

赞同来自:

下载.png

 

要回复问题请先

商务合作
商务合作