竖屏UI适配

This commit is contained in:
2025-06-04 10:05:42 +08:00
parent b18fefa905
commit 4c7d4b15ce
3 changed files with 84 additions and 52 deletions

View File

@@ -50,17 +50,16 @@ export class UIManager extends Laya.Script {
private UIRoot: Laya.Panel
public getUIRoot(): Laya.Node {
if (!this.UIRoot) {
this.UIRoot = this.owner.getChildByName("UIRoot") as Laya.Panel
if (config.H_SCREEN) {
if (config.H_SCREEN) {
if (!this.UIRoot) {
this.UIRoot = this.owner.getChildByName("UIRoot") as Laya.Panel
this.UIRoot.width = config.DESIGN_HEIGHT
this.UIRoot.height = config.DESIGN_WIDTH
} else {
this.UIRoot.width = config.DESIGN_WIDTH
this.UIRoot.height = config.DESIGN_HEIGHT
}
return this.UIRoot
} else {
return this.owner
}
return this.UIRoot
}
private topbar: TopBar

View File

@@ -12,6 +12,10 @@ const { regClass, property } = Laya
export class DailyChallenge extends Laya.Script {
declare owner: Laya.Box
@property(Laya.Sprite)
public sprite_bottom: Laya.Sprite
@property(Laya.Button)
public btn_back: Laya.Button
@@ -85,6 +89,12 @@ export class DailyChallenge extends Laya.Script {
onAwake(): void {
DailyChallenge._instance = this
if (!config.H_SCREEN) {
const parent = this.sprite_bottom.parent as Laya.Box
this.sprite_bottom.graphics.clear()
this.sprite_bottom.graphics.drawRoundRect(0, 0, parent.width, parent.height, 72, 72, 0, 0, "#ffffff")
}
if (this.btn_back) {
this.btn_back.on(Laya.Event.CLICK, this, () => {
UIManager.getInstance().loadHomeUI()
@@ -296,5 +306,7 @@ export class DailyChallenge extends Laya.Script {
UIManager.getInstance().loadTrophyClaimUI(find)
user.set_trophyNew(find, false)
}
}
}