// Learn TypeScript: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html // Learn Attribute: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html import Common5 from "../../../Platform/th/Common5"; const { ccclass, property } = cc._decorator; @ccclass export default class guiyin extends cc.Component { // LIFE-CYCLE CALLBACKS: // onLoad () {} start() { } run(nodes, callback) { let suipians = [3035, 3036, 3037, 3038, 3039] let suipianNodes = [] let positions = [] for (let i = 0; i < suipians.length; i++) { suipianNodes[i] = this.node.getChildByName(`${suipians[i]}`) positions[i] = suipianNodes[i].position.clone() } this.node.getChildByName("3040").active = false for (let i = 0; i < nodes.length; i++) { let targetLocalPos = nodes[i].getPosition() //目标节点的世界坐标 let targetWorldPos = nodes[i].parent.convertToWorldSpaceAR(targetLocalPos) // console.log(targetWorldPos) //目标节点相对于当前节点父节点的本地坐标 let localPos = this.node.parent.convertToNodeSpaceAR(targetWorldPos) // console.log(localPos) suipianNodes[i].setPosition(localPos) cc.tween(suipianNodes[i]) .sequence( cc.tween().to(0.5, { position: positions[i] }), cc.tween().delay(0.5), cc.tween().call(() => { if (i == nodes.length - 1) { for (let i = 0; i < suipians.length; i++) { suipianNodes[i].active = false } this.node.getChildByName("3040").active = true if (callback) { callback() } this.node.destroy() } }) ) .start() } } // update (dt) {} }