SectionBtn.ts 1.04 KB
import { DummyLabel, DummyNode } from "../../common/CCDummyObjects";
import { GameModelManager } from "../model/GameModelManager";

const { ccclass, property } = cc._decorator;

@ccclass
export default class SectionBtn extends cc.Component {

    @property(cc.Label)
    private label = DummyLabel;
    @property(cc.Node)
    private pointSpr = DummyNode;

    private _callback: Function;

    setData(chapterId: number, chapterName: string, isCurrChapter: boolean, callback: Function) {
        this._callback = callback;
        this.label.string = chapterId.toString() + "." + chapterName;
        if (isCurrChapter) {
            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();
            this.label.node.color = cc.color(255, 238, 149, 255);
        }
    }

    onItemClick() {
        this._callback();
    }

}