ChapterBtn.ts
1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { DummyLabel, DummyNode } from "../../common/CCDummyObjects";
import { GameModelManager } from "../model/GameModelManager";
const { ccclass, property } = cc._decorator;
@ccclass
export default class ChapterBtn extends cc.Component {
@property(cc.Label)
private label = DummyLabel;
@property(cc.Node)
private pointSpr = DummyNode;
private _pid: number = -1;
setData(chapterId: number, chapterName: number, pid: number) {
this._pid = pid;
this.label.string = chapterId.toString() + "." + GameModelManager.getI18LanguageTxt(chapterName);
}
onItemClick() {
console.log("onItemClick pid = ", this._pid);
GameModelManager.RollBackToPlot.emit(this._pid);
let sprites = this.node.parent.getComponentsInChildren(cc.Sprite);
for (let i = 0; i < sprites.length; i++) {
sprites[i].node.active = false;
}
this.pointSpr.active = true;
cc.tween(this.pointSpr)
.repeatForever(cc.tween()
.to(0.5, { scale: 1.15, x: -25 }, { easing: 'sineInOut' })
.to(0.5, { scale: 1, x: -30 }, { easing: 'sineInOut' }))
.start();
let labels = this.node.parent.getComponentsInChildren(cc.Label);
for (let i = 0; i < labels.length; i++) {
labels[i].node.color = cc.color(255, 255, 255, 255);
}
this.label.node.color = cc.color(255, 238, 149, 255);
}
}