我智商爆棚
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.
 
 
 
 
 

94 lines
2.4 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 DuiHuaScript extends cc.Component {
@property(cc.Label)
duiLabel: cc.Label = null;
@property(cc.Node)
duihuaNode: cc.Node = null;
// LIFE-CYCLE CALLBACKS:
// onLoad () {}
endCallFunc = null
duihuaArray:{log:string, effectUrl:string, delayTime:3.0}[] = []
duihuaIndex = 0
bundleName = null
start () {
}
setDuihuaPosiChange(){
this.duihuaNode.setPosition(cc.v2(0,0))
}
setDuihuaArray(bundleName,duihuaArray, callFunc?:Function){
this.bundleName = bundleName
this.duihuaNode.setPosition(cc.v2(0,-322))
this.duihuaIndex = 0
this.endCallFunc = callFunc
this.duihuaArray = duihuaArray
this.duihua(bundleName)
this.autoDuihua()
}
duihua(bundleName){
let data_ = this.duihuaArray[this.duihuaIndex]
this.duiLabel.string = data_.log
if( data_.effectUrl && data_.effectUrl.length>0){
Common5.playEffectCustom(bundleName, data_.effectUrl)
}
}
nextDuiHuaClickEvent(){
this.duihuaNode.stopAllActions()
this.duihuaIndex++
if(this.duihuaIndex <= this.duihuaArray.length-1){
this.duihua(this.bundleName)
this.autoDuihua()
}else{
this.endDuihua()
}
}
autoDuihua(){
this.duihuaNode.stopAllActions()
let data_ = this.duihuaArray[this.duihuaIndex]
let time = data_.delayTime
cc.tween(this.duihuaNode)
.delay(time)
.call(()=>{
this.duihuaIndex++
if(this.duihuaIndex <= this.duihuaArray.length-1){
this.duihua(this.bundleName)
this.autoDuihua()
}else{
this.endDuihua()
}
})
.start()
}
endDuihua(){
if(this.endCallFunc){
this.endCallFunc()
}
console.log('endDuihua')
this.node.active = false
}
// update (dt) {}
}