From 5e85db76f17b76b751fa8c8e7591672bbafb923b Mon Sep 17 00:00:00 2001 From: zhl Date: Tue, 26 Feb 2019 16:28:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9B=B4=E6=96=B0=E6=8B=BC?= =?UTF-8?q?=E5=9B=BE=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/scripts/puzzle.js | 12 ++++++++++-- assets/scripts/scrollContent.js | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/assets/scripts/puzzle.js b/assets/scripts/puzzle.js index 389c66b..f7ba1aa 100644 --- a/assets/scripts/puzzle.js +++ b/assets/scripts/puzzle.js @@ -9,13 +9,14 @@ cc.Class({ imageNode: { default: null, type: cc.Node - } + }, + imgs: [] }, // LIFE-CYCLE CALLBACKS: onLoad () { - for (let i = 0; i < 5; i++) { + for (let i = 0; i < 9; i++) { var img = cc.instantiate(this.imagePrefab); img.getComponent('puzzleImage').imgIndex = i; img.getComponent('puzzleImage').type = 0; @@ -33,6 +34,8 @@ cc.Class({ x = 202; } img.setPosition(cc.v2(x, y)); + img.active = false; + this.imgs.push(img); } }, @@ -41,4 +44,9 @@ cc.Class({ }, // update (dt) {}, + updateValues(valArr) { + for(let i = 0; i < this.imgs.length; i++) { + this.imgs[i].active = !!valArr[i] + } + } }); diff --git a/assets/scripts/scrollContent.js b/assets/scripts/scrollContent.js index 6cd6075..c2aacb6 100644 --- a/assets/scripts/scrollContent.js +++ b/assets/scripts/scrollContent.js @@ -83,6 +83,7 @@ cc.Class({ let self = this; this.scheduleOnce(function () { processBar.getComponent('progressBar').updateShow(35000); + puzzle.getComponent('puzzle').updateValues([0,1,0,1,0,1,1,0,1]) }, 5); },