如何根据success的状态来运行不同的action(如何让第一个if执行之后再执行第二个if)。没系统学过js,求指点。
click() {
const up = cc.moveTo(0.5, 30, 30)
let result = cc.callFunc(function () {
// 第一个if
if (成功) {
this.success = true
} else {
this.success = false
}
}, this)
// 第二个if
if (this.success === true) {
let down1 = cc.moveTo(0.5, 30, -600)
let sequence = cc.sequence(up, result, down1)
this.action = this.rope_node.runAction(sequence)
} else {
let down2 = cc.moveTo(0.5, 30, 600)
let sequence = cc.sequence(up, result, down2)
this.action = this.rope_node.runAction(sequence)
}
}
