|
@@ -1,4 +1,5 @@
|
|
import { _decorator, Component, Label, Node, Tween, tween, UITransform, Vec3 } from 'cc';
|
|
import { _decorator, Component, Label, Node, Tween, tween, UITransform, Vec3 } from 'cc';
|
|
|
|
+import { guangboData } from '../../data';
|
|
const { ccclass, property } = _decorator;
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
@ccclass('home_guangbo')
|
|
@ccclass('home_guangbo')
|
|
@@ -6,23 +7,24 @@ export class home_guangbo extends Component {
|
|
@property(Node) lab_1:Node = null
|
|
@property(Node) lab_1:Node = null
|
|
@property(Node) lab_2:Node = null
|
|
@property(Node) lab_2:Node = null
|
|
private cur_index = 0
|
|
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 data_list:guangboData[] = []
|
|
|
|
+
|
|
|
|
+ init(data_list:guangboData[]) {
|
|
|
|
+ this.data_list = data_list
|
|
|
|
+ this.lab_1.getComponent(Label).string = this.data_list[this.cur_index].title
|
|
|
|
+ this.unscheduleAllCallbacks()
|
|
|
|
+ this.schedule(()=>{
|
|
|
|
+ this.cur_index++
|
|
|
|
+ if(this.cur_index>=this.data_list.length) {
|
|
|
|
+ this.cur_index = 0
|
|
|
|
+ }
|
|
|
|
+ this.lab_1.getComponent(Label).string = this.data_list[this.cur_index].title
|
|
|
|
+ },2.5)
|
|
}
|
|
}
|
|
|
|
|
|
private startSchedule() {
|
|
private startSchedule() {
|
|
// this.lab_2.active = false
|
|
// this.lab_2.active = false
|
|
- this.setText(this.lab_1, this.data_list[this.cur_index])
|
|
|
|
|
|
+ this.setText(this.lab_1, this.data_list[this.cur_index].title)
|
|
this.schedule(()=>{
|
|
this.schedule(()=>{
|
|
this.cur_index ++
|
|
this.cur_index ++
|
|
this.runFrame(this.lab_1)
|
|
this.runFrame(this.lab_1)
|
|
@@ -31,7 +33,7 @@ export class home_guangbo extends Component {
|
|
this.cur_index = 0
|
|
this.cur_index = 0
|
|
}
|
|
}
|
|
|
|
|
|
- },2)
|
|
|
|
|
|
+ },2.5)
|
|
}
|
|
}
|
|
|
|
|
|
private stopSchedule() {
|
|
private stopSchedule() {
|
|
@@ -47,7 +49,7 @@ export class home_guangbo extends Component {
|
|
// current_node.active = false
|
|
// current_node.active = false
|
|
current_node.setPosition(new Vec3(0,-50,0))
|
|
current_node.setPosition(new Vec3(0,-50,0))
|
|
} else if(later_y==0) {
|
|
} else if(later_y==0) {
|
|
- this.setText(current_node, this.data_list[this.cur_index])
|
|
|
|
|
|
+ this.setText(current_node, this.data_list[this.cur_index].title)
|
|
current_node.active = true
|
|
current_node.active = true
|
|
} else if(later_y==-50) {
|
|
} else if(later_y==-50) {
|
|
current_node.active = false
|
|
current_node.active = false
|
|
@@ -57,7 +59,6 @@ export class home_guangbo extends Component {
|
|
|
|
|
|
private setText(current_node:Node, str:string) {
|
|
private setText(current_node:Node, str:string) {
|
|
current_node.getComponent(Label).string = '恭喜广州吴彦祖-' + str
|
|
current_node.getComponent(Label).string = '恭喜广州吴彦祖-' + str
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|