增加更新拼图的方法

This commit is contained in:
zhl 2019-02-26 16:28:02 +08:00
parent 2cfd778e4e
commit 5e85db76f1
2 changed files with 11 additions and 2 deletions

View File

@ -9,13 +9,14 @@ cc.Class({
imageNode: { imageNode: {
default: null, default: null,
type: cc.Node type: cc.Node
} },
imgs: []
}, },
// LIFE-CYCLE CALLBACKS: // LIFE-CYCLE CALLBACKS:
onLoad () { onLoad () {
for (let i = 0; i < 5; i++) { for (let i = 0; i < 9; i++) {
var img = cc.instantiate(this.imagePrefab); var img = cc.instantiate(this.imagePrefab);
img.getComponent('puzzleImage').imgIndex = i; img.getComponent('puzzleImage').imgIndex = i;
img.getComponent('puzzleImage').type = 0; img.getComponent('puzzleImage').type = 0;
@ -33,6 +34,8 @@ cc.Class({
x = 202; x = 202;
} }
img.setPosition(cc.v2(x, y)); img.setPosition(cc.v2(x, y));
img.active = false;
this.imgs.push(img);
} }
}, },
@ -41,4 +44,9 @@ cc.Class({
}, },
// update (dt) {}, // update (dt) {},
updateValues(valArr) {
for(let i = 0; i < this.imgs.length; i++) {
this.imgs[i].active = !!valArr[i]
}
}
}); });

View File

@ -83,6 +83,7 @@ cc.Class({
let self = this; let self = this;
this.scheduleOnce(function () { this.scheduleOnce(function () {
processBar.getComponent('progressBar').updateShow(35000); processBar.getComponent('progressBar').updateShow(35000);
puzzle.getComponent('puzzle').updateValues([0,1,0,1,0,1,1,0,1])
}, 5); }, 5);
}, },