123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- import { _decorator, Component, Label, Node, Tween, tween, UITransform, Vec3 } from 'cc';
- const { ccclass, property } = _decorator;
- @ccclass('home_guangbo')
- export class home_guangbo extends Component {
- @property(Node) lab_1:Node = null
- @property(Node) lab_2:Node = null
- private cur_index = 0
- private data_list:string[] = ['1','2','3','4']
- init() {
- // this.setText(this.lab_1, this.data_list[this.cur_index])
- // this.schedule(()=>{
- // this.cur_index++
- // if(this.cur_index>=this.data_list.length) {
- // this.cur_index = 0
- // }
- // this.setText(this.lab_1, this.data_list[this.cur_index])
-
- // },2)
- }
- private startSchedule() {
- // this.lab_2.active = false
- this.setText(this.lab_1, this.data_list[this.cur_index])
- this.schedule(()=>{
- this.cur_index ++
- this.runFrame(this.lab_1)
- this.runFrame(this.lab_2)
- if(this.cur_index>=this.data_list.length) {
- this.cur_index = 0
- }
- },2)
- }
- private stopSchedule() {
- this.unscheduleAllCallbacks()
- }
- private runFrame(current_node:Node) {
- let cur_y = current_node.getPosition().y
- tween(current_node).to(0.5,{position: new Vec3(0,cur_y+50,0)},{
- }).call(()=>{
- let later_y = current_node.getPosition().y
- if(later_y==50) {
- // current_node.active = false
- current_node.setPosition(new Vec3(0,-50,0))
- } else if(later_y==0) {
- this.setText(current_node, this.data_list[this.cur_index])
- current_node.active = true
- } else if(later_y==-50) {
- current_node.active = false
- }
- }).start()
- }
- private setText(current_node:Node, str:string) {
- current_node.getComponent(Label).string = '恭喜广州吴彦祖-' + str
- }
- }
|