var manager = cc.Class({
extends: cc.Component,
properties: {
layerNum: {
type: cc.Integer, //使用整型定义
default: 0,
//使用notify函数监听属性变化
notify(oldValue) {
//减少无效赋值
if (oldValue === this.layerNum) {
return;
}
// this.node.index = this.layerNum;
this.index = this.layerNum;
}
}
},
// LIFE-CYCLE CALLBACKS:
// onLoad () {},
start () {
// this.node.index = this.layerNum
this.index = this.layerNum
var self = this
// cc.log(this)
// cc.log(this.node)
// this.node.index = 0
// cc.log(children)
this.children = this.node.getChildren();
// cc.log(this.children)
this.children.forEach(function(item, index){
// cc.log(self.node.index)
// cc.log(index)
if(self.index === index){
item.active = true
}else{
item.active = false
}
})
},
next () {
var children = this.children
// cc.log(children)
// cc.log(this.index, children.length)
// cc.log(this.index < children.length)
if(this.index < children.length - 1){
// children[this.index].active = false
// children[this.index+1].active = true
children[this.index].runAction(cc.fadeOut(0.8))
children[this.index+1].opacity = 0
children[this.index+1].active = true
children[this.index+1].runAction(cc.fadeIn(0.8))
this.index++
}else{
cc.log('finish')
}
}
// update (dt) {},
});
网友评论