| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- // 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 GuideLabel extends cc.Component {
- // LIFE-CYCLE CALLBACKS:
- // onLoad () {}
- private labelStr = ""
- private isShow = false
- start () {
- // if(this.isShow){
- // return
- // }
- this.setView()
- }
-
- setView(){
- this.node.color = cc.color(233,136,78)
- let label = this.node.getComponent(cc.Label)
- if(!cc.isValid(label)){
- return
- }
- // if(this.isShow){
- // return
- // }
- this.isShow = true
- label.enableBold = true
- // this.labelStr = label.string
- // this.showTalk(0,this.labelStr)
- }
- onEnable(){
-
- }
- showTalk(index: number, str: string) {
- index++
- if (index > str.length) {
- return
- }
- if(!cc.isValid(this.node)){
- return
- }
- let showStr = str.substr(0, index)
- this.node.getComponent(cc.Label).string = showStr
- this.scheduleOnce(() => {
- this.showTalk(index, str)
- }, 0.06)
- }
- // update (dt) {}
- }
|