增加图片预加载逻辑
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { config } from "../constants/config"
|
||||
import { respath } from "../constants/respath"
|
||||
import { G_getMonthInfo } from "../models/DCManager"
|
||||
import { ResourceManager } from "../models/ResourceManager"
|
||||
import { StorageManager } from "../models/StorageManager"
|
||||
import { UIManager } from "../models/UIManager"
|
||||
import { Utility_ConvertSecondToString } from "../utils/utility"
|
||||
@@ -42,8 +43,7 @@ export class Home extends Laya.Script {
|
||||
@property(Laya.Box)
|
||||
public btn_new_white: Laya.Box
|
||||
|
||||
// 组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次
|
||||
onAwake(): void {
|
||||
onStart(): void {
|
||||
const user = StorageManager.getInstance().getUser()
|
||||
const now = new Date()
|
||||
const nowYear = now.getFullYear()
|
||||
@@ -51,18 +51,18 @@ export class Home extends Laya.Script {
|
||||
const nowDay = now.getDate()
|
||||
const find = G_getMonthInfo(nowYear, nowMonth)
|
||||
if (find) {
|
||||
this.icon_dc.skin = find.icon_res
|
||||
ResourceManager.getInstance().loadTexture(find.icon_res, this.icon_dc)
|
||||
if (user.get_trophyRecord(nowYear, nowMonth)) {
|
||||
this.bg_dc.skin = respath.home_top_dc_bg_finish
|
||||
ResourceManager.getInstance().loadTexture(respath.home_top_dc_bg_finish, this.bg_dc)
|
||||
this.label_dc_title.color = "#ffffff"
|
||||
this.label_dc_date.color = "#ffffff"
|
||||
} else {
|
||||
this.bg_dc.skin = respath.home_top_dc_bg_normal
|
||||
ResourceManager.getInstance().loadTexture(respath.home_top_dc_bg_normal, this.bg_dc)
|
||||
this.label_dc_title.color = "#2d3138"
|
||||
this.label_dc_date.color = "#2d3138"
|
||||
}
|
||||
} else {
|
||||
this.bg_dc.skin = respath.home_top_dc_bg_normal
|
||||
ResourceManager.getInstance().loadTexture(respath.home_top_dc_bg_normal, this.bg_dc)
|
||||
this.label_dc_title.color = "#2d3138"
|
||||
this.label_dc_date.color = "#2d3138"
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { config } from "../../constants/config"
|
||||
import { respath } from "../../constants/respath"
|
||||
import { MONTH_LIST } from "../../models/DCManager"
|
||||
import { EVENT_TYPES, EventManager } from "../../models/EventManager"
|
||||
import { ResourceManager } from "../../models/ResourceManager"
|
||||
import { StorageManager } from "../../models/StorageManager"
|
||||
import { UIManager } from "../../models/UIManager"
|
||||
import { Utility_ConvertSecondToString } from "../../utils/utility"
|
||||
@@ -188,14 +189,14 @@ export class DailyChallenge extends Laya.Script {
|
||||
const nowMonth = now.getMonth() + 1
|
||||
const nowDay = new Date().getDate()
|
||||
|
||||
this.trophy_icon.skin = info.icon_res
|
||||
ResourceManager.getInstance().loadTexture(info.icon_res, this.trophy_icon)
|
||||
// 设置背景
|
||||
if (user.get_trophyRecord(info.year, info.month)) {
|
||||
this.bg_dc.skin = respath.dc_top_bg_month_finish
|
||||
ResourceManager.getInstance().loadTexture(respath.dc_top_bg_finish, this.bg_dc)
|
||||
this.trophy_light.visible = true
|
||||
this.trophy_icon.gray = false
|
||||
} else {
|
||||
this.bg_dc.skin = respath.dc_top_bg_normal
|
||||
ResourceManager.getInstance().loadTexture(respath.dc_top_bg_normal, this.bg_dc)
|
||||
this.trophy_light.visible = false
|
||||
this.trophy_icon.gray = true
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { TrophyRecord } from "../../types/global"
|
||||
import { config } from "../../constants/config"
|
||||
import { MONTH_LIST } from "../../models/DCManager"
|
||||
import { ResourceManager } from "../../models/ResourceManager"
|
||||
|
||||
const { regClass, property } = Laya
|
||||
|
||||
@@ -21,7 +22,7 @@ export class TrophyClaim extends Laya.Script {
|
||||
for (let i = 0; i < MONTH_LIST.length; i++) {
|
||||
const obj = MONTH_LIST[i]
|
||||
if (obj.year === record.year && obj.month === record.month) {
|
||||
this.icon.skin = obj.icon_res
|
||||
ResourceManager.getInstance().loadTexture(obj.icon_res, this.icon)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { TrophyRecord } from "../../types/global"
|
||||
import { config } from "../../constants/config"
|
||||
import { MONTH_LIST } from "../../models/DCManager"
|
||||
import { ResourceManager } from "../../models/ResourceManager"
|
||||
|
||||
const { regClass, property } = Laya
|
||||
|
||||
@@ -21,7 +22,7 @@ export class TrophyShow extends Laya.Script {
|
||||
for (let i = 0; i < MONTH_LIST.length; i++) {
|
||||
const obj = MONTH_LIST[i]
|
||||
if (obj.year === record.year && obj.month === record.month) {
|
||||
this.icon.skin = obj.icon_res
|
||||
ResourceManager.getInstance().loadTexture(obj.icon_res, this.icon)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { config } from "../../constants/config"
|
||||
import { respath } from "../../constants/respath"
|
||||
import { ResourceManager } from "../../models/ResourceManager"
|
||||
import { StorageManager } from "../../models/StorageManager"
|
||||
import { UIManager } from "../../models/UIManager"
|
||||
|
||||
@@ -24,15 +25,15 @@ export class TrophyUnit extends Laya.Script {
|
||||
public onInit(info: any): void {
|
||||
const user = StorageManager.getInstance().getUser()
|
||||
const starCount = user.get_doneCountByDate(info.year, info.month)
|
||||
this.icon.skin = info.icon_res
|
||||
ResourceManager.getInstance().loadTexture(info.icon_res, this.icon)
|
||||
this.label_count.text = `${starCount}/${info.dayCount}`
|
||||
this.label_month.text = config.MONTH_ABBRS[info.month - 1]
|
||||
if (user.get_trophyRecord(info.year, info.month)) {
|
||||
this.bg_light.skin = respath.trophy_bg_light_gold
|
||||
ResourceManager.getInstance().loadTexture(respath.trophy_bg_light_gold, this.bg_light)
|
||||
this.icon.gray = false
|
||||
this.label_month.color = "#2d3138"
|
||||
} else {
|
||||
this.bg_light.skin = respath.trophy_bg_light_grey
|
||||
ResourceManager.getInstance().loadTexture(respath.trophy_bg_light_grey, this.bg_light)
|
||||
this.icon.gray = true
|
||||
this.label_month.color = "#a7abb3"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user