觉醒时刻
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

64 lines
2.2 KiB

// 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 huyin extends cc.Component {
// LIFE-CYCLE CALLBACKS:
// onLoad () {}
start() {
}
run(nodes, callback) {
let suipians = [3048, 3049, 3050, 3764, 3765]
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("3051").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("3051").active = true
if (callback) {
callback()
}
this.node.destroy()
}
})
)
.start()
}
}
// update (dt) {}
}