89 lines
2.7 KiB
TypeScript
89 lines
2.7 KiB
TypeScript
// Learn TypeScript:
|
|
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
|
|
// Learn Attribute:
|
|
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
|
|
// Learn life-cycle callbacks:
|
|
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
|
|
|
|
const { ccclass, property } = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class NewClass extends cc.Component {
|
|
can_Touch: boolean;
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
onLoad() {
|
|
this.can_Touch = false;
|
|
}
|
|
|
|
start() {
|
|
|
|
}
|
|
|
|
init(data) {
|
|
this.can_Touch = false;
|
|
this.node.getChildByName("win").active = false;
|
|
this.node.getChildByName("lose").active = false;
|
|
this.node.getChildByName("finishi").active = false;
|
|
this.node.getChildByName(data.result).active = true;
|
|
if (data.result == "lose") {
|
|
this.setErrLabel(data.code);
|
|
}
|
|
var target = this.node.getChildByName(data.result);
|
|
target.getChildByName("btn").active = false;
|
|
target.opacity = 0; target.scale = 2; target.getChildByName("tip").opacity = 0;
|
|
if (data.result == "win") {
|
|
var lianXi = false;
|
|
if (cc.fx.GameConfig.GM_INFO.level == 2) lianXi = true;
|
|
target.getChildByName("yes").active = !lianXi;
|
|
target.getChildByName("start").active = lianXi;
|
|
}
|
|
cc.tween(target)
|
|
.delay(0.1)
|
|
.to(0.25, { opacity: 255, scale: 1 })
|
|
.delay(0.3)
|
|
.call(() => {
|
|
if (target.name == "lose") {
|
|
cc.tween(target.getChildByName("tip"))
|
|
.to(0.5, { opacity: 255 })
|
|
.delay(0.5)
|
|
.call(() => {
|
|
this.can_Touch = true;
|
|
target.getChildByName("btn").active = true;
|
|
})
|
|
.start();
|
|
}
|
|
else {
|
|
this.can_Touch = true;
|
|
target.getChildByName("btn").active = true;
|
|
}
|
|
|
|
})
|
|
.start();
|
|
}
|
|
|
|
setErrLabel(code) {
|
|
var tip = this.node.getChildByName("lose").getChildByName("tip").getComponent(cc.Label);
|
|
tip.string = cc.fx.GameConfig.TIP_ERR[code];
|
|
}
|
|
|
|
click_Next() {
|
|
if (!this.can_Touch) {
|
|
return;
|
|
}
|
|
this.can_Touch = false;
|
|
cc.tween(this.node)
|
|
.to(0.3, { opacity: 0 })
|
|
.call(() => {
|
|
if (this.node) {
|
|
this.node.active = false;
|
|
}
|
|
cc.director.loadScene("GameScene");
|
|
})
|
|
.start();
|
|
}
|
|
|
|
// update (dt) {}
|
|
}
|