日历添加左右按钮

This commit is contained in:
2025-06-03 19:36:55 +08:00
parent cc6efbc801
commit ce90518d06
3 changed files with 168 additions and 17 deletions

View File

@@ -33,6 +33,12 @@ export class DailyChallenge extends Laya.Script {
@property(Laya.Box)
public btn_right: Laya.Box
@property(Laya.Box)
public btn_left2: Laya.Box
@property(Laya.Box)
public btn_right2: Laya.Box
@property(Laya.Image)
public bg_dc: Laya.Image
@@ -128,18 +134,12 @@ export class DailyChallenge extends Laya.Script {
break
}
}
this.btn_left.on(Laya.Event.CLICK, this, () => {
if (this.currentIndex > 0) {
this.currentIndex--
this.loadWithIndex(this.currentIndex)
}
})
this.btn_right.on(Laya.Event.CLICK, this, () => {
if (this.currentIndex < this.indexMax) {
this.currentIndex++
this.loadWithIndex(this.currentIndex)
}
})
this.btn_left.on(Laya.Event.CLICK, this, this.onClickLeft)
this.btn_right.on(Laya.Event.CLICK, this, this.onClickRight)
this.btn_left2.on(Laya.Event.CLICK, this, this.onClickLeft)
this.btn_right2.on(Laya.Event.CLICK, this, this.onClickRight)
EventManager.getInstance().RegisterEvent(EVENT_TYPES.NOT_SET_TROPHY_BUTTON, DailyChallenge.EventUpdateTrophyButton)
}
@@ -169,6 +169,8 @@ export class DailyChallenge extends Laya.Script {
public loadWithIndex(index: number): void {
this.btn_left.visible = this.currentIndex > 0
this.btn_right.visible = this.currentIndex < this.indexMax
this.btn_left2.visible = this.currentIndex > 0
this.btn_right2.visible = this.currentIndex < this.indexMax
const info = MONTH_LIST[index]
UIManager.getInstance().setCurrentDCMonth(info.year, info.month)
console.log("DailyChallenge loadWithIndex >>>>>>>>>>>>>>>", info.year, info.month)
@@ -274,6 +276,21 @@ export class DailyChallenge extends Laya.Script {
this.onApplyUnit(unit)
}
onClickLeft(): void {
if (this.currentIndex > 0) {
this.currentIndex--
this.loadWithIndex(this.currentIndex)
}
}
onClickRight(): void {
if (this.currentIndex < this.indexMax) {
this.currentIndex++
this.loadWithIndex(this.currentIndex)
}
}
onStart(): void {
const user = StorageManager.getInstance().getUser()
const find = user.get_trophyHasNew()