From 66e6d4db4a371791fa6cea47fb6b12076acd1711 Mon Sep 17 00:00:00 2001 From: Next <1406099478@qq.com> Date: Fri, 8 Mar 2019 20:24:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8D=E5=BC=80=E5=90=AF=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E6=A0=91=E6=97=B6=E4=B9=9F=E5=8F=AF=E4=BB=A5cc.tree?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 102 ++++++++++++++++++++++++++++++--------------------- version.json | 2 +- 2 files changed, 62 insertions(+), 42 deletions(-) diff --git a/index.html b/index.html index 017102e..49ae87d 100644 --- a/index.html +++ b/index.html @@ -362,37 +362,29 @@ return node.name.toLowerCase().indexOf(value.toLowerCase()) !== -1; }, openDevMode() { - let initWin = () => { - if (window.cc) { - cc.js.getset(cc.Node.prototype, 'isLeaf', function () { - return this.childrenCount === 0; - }, function (value) { + setTimeout(() => { + cc.js.getset(cc.Node.prototype, 'isLeaf', function () { + return this.childrenCount === 0; + }, function (value) { - }, false, true); - let top = document.getElementById('top') - top.appendChild(document.getElementsByClassName('toolbar')[0]); - document.getElementById('game_panel').appendChild(document.getElementById('content')); - let scene = cc.director.getScene(); - if (scene) { - this.updateTreeData(); - } - cc.director.on(cc.Director.EVENT_AFTER_SCENE_LAUNCH, () => { - this.updateTreeData(); - }, this); - cc.director.on(cc.Director.EVENT_BEFORE_SCENE_LOADING, () => { - this.$data.node = null; - this.$data.sceneTreeData = []; - this.$data.treeParam = []; - }, this); - this.initConsoleUtil(); - clearInterval(this.$data.intervalId); - } else { - // console.log('cc is not init'); + }, false, true); + let top = document.getElementById('top') + top.appendChild(document.getElementsByClassName('toolbar')[0]); + document.getElementById('game_panel').appendChild(document.getElementById('content')); + let scene = cc.director.getScene(); + if (scene) { + this.updateTreeData(); } - } - this.$data.intervalId = setInterval(initWin, 500); - setTimeout(initWin, 0); - localStorage.setItem('isDevMode', 1); + cc.director.on(cc.Director.EVENT_AFTER_SCENE_LAUNCH, () => { + this.updateTreeData(); + }, this); + cc.director.on(cc.Director.EVENT_BEFORE_SCENE_LOADING, () => { + this.$data.node = null; + this.$data.sceneTreeData = []; + this.$data.treeParam = []; + }, this); + localStorage.setItem('isDevMode', 1); + }, 0); }, closeDevMode() { this.$data.node = null; @@ -449,6 +441,17 @@ } animate(); }, + fitFullScreen() { + document.getElementsByClassName('toolbar')[0].style.display = 'none'; + let gameDiv = document.getElementById('GameDiv'); + let gameContainer = document.getElementById('Cocos2dGameContainer'); + let gameCanvas = document.getElementById('GameCanvas'); + gameDiv.style.width = '100%'; + gameDiv.style.height = '100%'; + gameCanvas.style.width = '100%'; + gameCanvas.style.height = '100%'; + // document.body.style.cssText+="-webkit-transform: rotate(-90deg);-moz-transform: rotate(-90deg)"; + }, initConsoleUtil() { if (cc.tree) return; cc.tree = function (key) { @@ -577,18 +580,35 @@ created: function () { this.checkVersion(); document.body.insertBefore(document.getElementById('app'), document.body.firstChild); - if (localStorage.getItem('isDevMode') === '1') { - this.$data.isDevMode = true; - this.openDevMode(); - } else { - this.$data.isDevMode = false; + + let onCCInit = () => { + this.initConsoleUtil(); + if (cc.sys.isMobile) { + this.fitFullScreen(); + } + if (localStorage.getItem('isDevMode') === '1') { + this.$data.isDevMode = true; + this.openDevMode(); + } else { + this.$data.isDevMode = false; + } + this.$data.isShowFPS = localStorage.getItem('isShowFPS') === '1'; + this.$data.isShowMS = localStorage.getItem('isShowMS') === '1'; + this.$data.isShowMB = localStorage.getItem('isShowMB') === '1'; + setTimeout(() => { + this.handleChangeStats(); + }, 0); } - this.$data.isShowFPS = localStorage.getItem('isShowFPS') === '1'; - this.$data.isShowMS = localStorage.getItem('isShowMS') === '1'; - this.$data.isShowMB = localStorage.getItem('isShowMB') === '1'; - setTimeout(() => { - this.handleChangeStats(); - }, 0); + let checkCC = () => { + if (window.cc) { + onCCInit(); + clearInterval(this.$data.intervalId); + } else { + // console.log('cc is not init'); + } + } + this.$data.intervalId = setInterval(checkCC, 500); + setTimeout(checkCC, 0); }, }); - \ No newline at end of file + diff --git a/version.json b/version.json index 76ed899..fdd3149 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "name": "ccc-devtools", - "version": "2.1.0", + "version": "2.1.1", "author": "Next", "repo": "https://github.com/potato47/ccc-devtools.git" } \ No newline at end of file