41 lines
970 B
JavaScript
41 lines
970 B
JavaScript
cc.Class({
|
|
extends: cc.Component,
|
|
|
|
properties: {
|
|
pb_cell: {
|
|
default: null,
|
|
type: cc.Prefab,
|
|
},
|
|
nd_add: {
|
|
default: null,
|
|
type: cc.Node,
|
|
},
|
|
|
|
},
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
start() {
|
|
cc.Notifier.on("getreward", this, this.getreward.bind(this));
|
|
},
|
|
onDestroy() {
|
|
cc.Notifier.off("getreward", this);
|
|
},
|
|
getreward() {
|
|
this.node.destroy()
|
|
},
|
|
initdata(v) {
|
|
for (var i = 0; i < v.items.length; i++) {
|
|
var nd = cc.instantiate(this.pb_cell)
|
|
nd.getComponent("cellreward").initdata(v.items[i])
|
|
this.nd_add.addChild(nd)
|
|
}
|
|
var self = this
|
|
var cb = cc.callFunc(function() {
|
|
self.node.destroy()
|
|
});
|
|
this.node.runAction(cc.sequence(cc.delayTime(0.5),cc.fadeOut(1), cb));
|
|
},
|
|
|
|
// update (dt) {},
|
|
}); |