开始添加横屏UI

This commit is contained in:
2025-05-23 20:47:03 +08:00
parent e0d25affa3
commit 354194358b
31 changed files with 58237 additions and 14257 deletions

View File

@@ -7,8 +7,8 @@
"top": 0,
"bottom": 0,
"name": "Scene2D",
"width": 1080,
"height": 1920,
"width": 1920,
"height": 1080,
"_$comp": [
{
"_$type": "7bad1742-6eed-4d8d-81c0-501dc5bf03d6",

Binary file not shown.

View File

@@ -0,0 +1,3 @@
{
"uuid": "7322bbf9-175b-4a25-a0d7-72d369894de2"
}

View File

@@ -50,19 +50,6 @@
}
],
"_$child": [
{
"_$id": "g2ct7a01",
"_$type": "Image",
"name": "Mask",
"width": 1080,
"height": 1920,
"left": 0,
"right": 0,
"top": 0,
"bottom": 0,
"skin": "res://a98f334e-ce04-4cd0-8fc5-bbdf9b048609",
"color": "#f5f7fb"
},
{
"_$id": "pnoy48ek",
"_$type": "Box",
@@ -297,10 +284,10 @@
"y": 0,
"width": 1,
"height": 1,
"lt": 20,
"rt": 20,
"lb": 20,
"rb": 20,
"lt": 36,
"rt": 36,
"lb": 36,
"rb": 36,
"percent": true,
"lineWidth": 1,
"fillColor": "rgba(29, 92, 220, 1)"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +1,3 @@
{
"uuid": "665f7342-64cb-4801-a000-041575e71bb5"
"uuid": "5228993d-78c0-41ae-bd57-ecb0c953ac15"
}

41452
assets/resources/Stage_H_DC.lh Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,3 @@
{
"uuid": "2704a5eb-4df2-47ba-9ebf-b1b998b645d5"
}

502
assets/resources/TopBar.lh Normal file
View File

@@ -0,0 +1,502 @@
{
"_$ver": 1,
"_$id": "n0oso5ht",
"_$type": "Box",
"name": "TopBar",
"width": 1920,
"height": 120,
"left": 0,
"right": 0,
"top": 0,
"_$child": [
{
"_$id": "stl71oaq",
"_$type": "HBox",
"name": "left",
"x": 44,
"width": 648,
"height": 120,
"left": 44,
"top": 0,
"bottom": 0,
"space": 20,
"align": "middle",
"_$child": [
{
"_$id": "u4b9ebng",
"_$type": "Box",
"name": "btn_classic",
"y": 24,
"width": 312,
"height": 72,
"_$child": [
{
"_$id": "9pp003sx",
"_$type": "Sprite",
"name": "Sprite",
"width": 312,
"height": 72,
"_gcmds": [
{
"_$type": "DrawRoundRectCmd",
"x": 0,
"y": 0,
"width": 1,
"height": 1,
"lt": 12,
"rt": 12,
"lb": 12,
"rb": 12,
"percent": true,
"lineWidth": 1,
"fillColor": "rgba(14, 42, 83, 1)"
}
]
},
{
"_$id": "3egrc2h4",
"_$type": "Label",
"name": "Label",
"width": 312,
"height": 72,
"left": 0,
"right": 0,
"top": 0,
"bottom": 0,
"text": "Classic Sudoku",
"font": "res://7322bbf9-175b-4a25-a0d7-72d369894de2",
"fontSize": 36,
"color": "#FFFFFF",
"align": "center",
"valign": "middle",
"padding": "0,0,0,0"
}
]
},
{
"_$id": "y4tagu3d",
"_$type": "Box",
"name": "btn_dc",
"x": 332,
"y": 24,
"width": 312,
"height": 72,
"_$child": [
{
"_$id": "kdgs3kw9",
"_$type": "Sprite",
"name": "Sprite",
"width": 312,
"height": 72,
"alpha": 0.1,
"_gcmds": [
{
"_$type": "DrawRoundRectCmd",
"x": 0,
"y": 0,
"width": 1,
"height": 1,
"lt": 12,
"rt": 12,
"lb": 12,
"rb": 12,
"percent": true,
"lineWidth": 1,
"fillColor": "rgba(14, 42, 83, 1)"
}
]
},
{
"_$id": "8bp5ph4p",
"_$type": "Label",
"name": "Label",
"width": 312,
"height": 72,
"left": 0,
"right": 0,
"top": 0,
"bottom": 0,
"text": "Daily Challenge",
"font": "res://7322bbf9-175b-4a25-a0d7-72d369894de2",
"fontSize": 36,
"color": "rgba(14, 42, 83, 1)",
"align": "center",
"valign": "middle",
"padding": "0,0,0,0",
"_$comp": [
{
"_$type": "cadd567d-5099-49b9-a9b3-b7c404d5fe1b",
"scriptPath": "../src/views/TopBar.ts",
"btn_classic": {
"_$ref": "u4b9ebng"
},
"sprite_classic": {
"_$ref": "9pp003sx"
},
"label_classic": {
"_$ref": "3egrc2h4"
},
"btn_dc": {
"_$ref": "y4tagu3d"
},
"sprite_dc": {
"_$ref": "kdgs3kw9"
},
"label_dc": {
"_$ref": "8bp5ph4p"
},
"obj_items": {
"_$ref": "6g0fjeca"
}
}
]
}
]
}
]
},
{
"_$id": "v2lfxxzc",
"_$type": "Box",
"name": "right",
"x": 866,
"width": 1054,
"height": 120,
"right": 0,
"top": 0,
"bottom": 0,
"_$child": [
{
"_$id": "c4v7pjor",
"_$type": "Label",
"name": "Label",
"x": -108,
"y": 30,
"width": 292,
"height": 60,
"centerY": 0,
"text": "Difficulty:",
"font": "res://7322bbf9-175b-4a25-a0d7-72d369894de2",
"fontSize": 36,
"color": "rgba(167, 171, 179, 1)",
"align": "center",
"valign": "middle",
"padding": "0,0,0,0"
},
{
"_$id": "6g0fjeca",
"_$type": "HBox",
"name": "items",
"x": 144,
"y": 30,
"width": 200,
"height": 60,
"centerY": 0,
"space": 20,
"align": "middle",
"_$child": [
{
"_$id": "2cbgfaxu",
"_$type": "Box",
"name": "Box(1)",
"width": 132,
"height": 60,
"_$comp": [
{
"_$type": "8857686b-9b2c-4e9c-af0f-0164c0994e46",
"scriptPath": "../src/views/common/CommonData.ts",
"intValue": 0,
"strValue": ""
}
],
"_$child": [
{
"_$id": "b2mvyk8s",
"_$type": "Sprite",
"name": "Sprite",
"width": 132,
"height": 60,
"alpha": 0.1,
"_gcmds": [
{
"_$type": "DrawRoundRectCmd",
"x": 0,
"y": 0,
"width": 1,
"height": 1,
"lt": 12,
"rt": 12,
"lb": 12,
"rb": 12,
"percent": true,
"lineWidth": 1,
"fillColor": "rgba(14, 42, 83, 1)"
}
]
},
{
"_$id": "rixxvje7",
"_$type": "Label",
"name": "Label",
"width": 132,
"height": 60,
"left": 0,
"right": 0,
"top": 0,
"bottom": 0,
"text": "Easy",
"font": "res://7322bbf9-175b-4a25-a0d7-72d369894de2",
"fontSize": 36,
"color": "rgba(14, 42, 83, 1)",
"align": "center",
"valign": "middle",
"padding": "0,0,0,0"
}
]
},
{
"_$id": "u5q1rxe8",
"_$type": "Box",
"name": "Box(2)",
"x": 152,
"width": 189,
"height": 60,
"_$comp": [
{
"_$type": "8857686b-9b2c-4e9c-af0f-0164c0994e46",
"scriptPath": "../src/views/common/CommonData.ts",
"intValue": 0,
"strValue": ""
}
],
"_$child": [
{
"_$id": "6rwertze",
"_$type": "Sprite",
"name": "Sprite",
"width": 189,
"height": 60,
"alpha": 0.1,
"_gcmds": [
{
"_$type": "DrawRoundRectCmd",
"x": 0,
"y": 0,
"width": 1,
"height": 1,
"lt": 12,
"rt": 12,
"lb": 12,
"rb": 12,
"percent": true,
"lineWidth": 1,
"fillColor": "rgba(14, 42, 83, 1)"
}
]
},
{
"_$id": "7et7pcm4",
"_$type": "Label",
"name": "Label",
"width": 189,
"height": 60,
"left": 0,
"right": 0,
"top": 0,
"bottom": 0,
"text": "Medium",
"font": "res://7322bbf9-175b-4a25-a0d7-72d369894de2",
"fontSize": 36,
"color": "rgba(14, 42, 83, 1)",
"align": "center",
"valign": "middle",
"padding": "0,0,0,0"
}
]
},
{
"_$id": "24u2dmu4",
"_$type": "Box",
"name": "Box(3)",
"x": 361,
"width": 132,
"height": 60,
"_$comp": [
{
"_$type": "8857686b-9b2c-4e9c-af0f-0164c0994e46",
"scriptPath": "../src/views/common/CommonData.ts",
"intValue": 0,
"strValue": ""
}
],
"_$child": [
{
"_$id": "swr0juum",
"_$type": "Sprite",
"name": "Sprite",
"width": 132,
"height": 60,
"alpha": 0.1,
"_gcmds": [
{
"_$type": "DrawRoundRectCmd",
"x": 0,
"y": 0,
"width": 1,
"height": 1,
"lt": 12,
"rt": 12,
"lb": 12,
"rb": 12,
"percent": true,
"lineWidth": 1,
"fillColor": "rgba(14, 42, 83, 1)"
}
]
},
{
"_$id": "47bub8da",
"_$type": "Label",
"name": "Label",
"width": 132,
"height": 60,
"left": 0,
"right": 0,
"top": 0,
"bottom": 0,
"text": "Hard",
"font": "res://7322bbf9-175b-4a25-a0d7-72d369894de2",
"fontSize": 36,
"color": "rgba(14, 42, 83, 1)",
"align": "center",
"valign": "middle",
"padding": "0,0,0,0"
}
]
},
{
"_$id": "tfj1gqhi",
"_$type": "Box",
"name": "Box(4)",
"x": 513,
"width": 162,
"height": 60,
"_$comp": [
{
"_$type": "8857686b-9b2c-4e9c-af0f-0164c0994e46",
"scriptPath": "../src/views/common/CommonData.ts",
"intValue": 0,
"strValue": ""
}
],
"_$child": [
{
"_$id": "ftn8440x",
"_$type": "Sprite",
"name": "Sprite",
"width": 162,
"height": 60,
"alpha": 0.1,
"_gcmds": [
{
"_$type": "DrawRoundRectCmd",
"x": 0,
"y": 0,
"width": 1,
"height": 1,
"lt": 12,
"rt": 12,
"lb": 12,
"rb": 12,
"percent": true,
"lineWidth": 1,
"fillColor": "rgba(14, 42, 83, 1)"
}
]
},
{
"_$id": "4wvr9z82",
"_$type": "Label",
"name": "Label",
"width": 162,
"height": 60,
"left": 0,
"right": 0,
"top": 0,
"bottom": 0,
"text": "Expert",
"font": "res://7322bbf9-175b-4a25-a0d7-72d369894de2",
"fontSize": 36,
"color": "rgba(14, 42, 83, 1)",
"align": "center",
"valign": "middle",
"padding": "0,0,0,0"
}
]
},
{
"_$id": "xqqjuftc",
"_$type": "Box",
"name": "Box(5)",
"x": 695,
"width": 192,
"height": 60,
"_$comp": [
{
"_$type": "8857686b-9b2c-4e9c-af0f-0164c0994e46",
"scriptPath": "../src/views/common/CommonData.ts",
"intValue": 0,
"strValue": ""
}
],
"_$child": [
{
"_$id": "f1ra9jda",
"_$type": "Sprite",
"name": "Sprite",
"width": 192,
"height": 60,
"alpha": 0.1,
"_gcmds": [
{
"_$type": "DrawRoundRectCmd",
"x": 0,
"y": 0,
"width": 1,
"height": 1,
"lt": 12,
"rt": 12,
"lb": 12,
"rb": 12,
"percent": true,
"lineWidth": 1,
"fillColor": "rgba(14, 42, 83, 1)"
}
]
},
{
"_$id": "3nceoiwj",
"_$type": "Label",
"name": "Label",
"width": 192,
"height": 60,
"left": 0,
"right": 0,
"top": 0,
"bottom": 0,
"text": "Extreme",
"font": "res://7322bbf9-175b-4a25-a0d7-72d369894de2",
"fontSize": 36,
"color": "rgba(14, 42, 83, 1)",
"align": "center",
"valign": "middle",
"padding": "0,0,0,0"
}
]
}
]
}
]
}
]
}

View File

@@ -0,0 +1,3 @@
{
"uuid": "96ad71b3-f8c9-47f0-a3c2-f6413f18e065"
}

View File

@@ -13,7 +13,7 @@
"_$comp": [
{
"_$type": "554595b0-0dd8-4e4b-8073-8d775219659c",
"scriptPath": "../src/views/TrophyRoom.ts",
"scriptPath": "../src/views/dc/TrophyRoom.ts",
"btn_back": {
"_$ref": "12tz34f8"
},
@@ -23,19 +23,6 @@
}
],
"_$child": [
{
"_$id": "lj5633i3",
"_$type": "Image",
"name": "bg",
"width": 1080,
"height": 1920,
"left": 0,
"right": 0,
"top": 0,
"bottom": 0,
"skin": "res://a98f334e-ce04-4cd0-8fc5-bbdf9b048609",
"color": "#f5f7fb"
},
{
"_$id": "z1p4zsvs",
"_$type": "Box",

View File

@@ -1,7 +1,8 @@
{
"resolution": {
"designWidth": 1080,
"designHeight": 1920
"designWidth": 1920,
"designHeight": 1080,
"backgroundColor": "rgba(245, 247, 251, 1)"
},
"modules": {
"laya.ui": true,

View File

@@ -4,19 +4,19 @@ import { config } from "./constants/config"
Laya.addBeforeInitCallback((stageConfig) => {
console.log(`window innerWidth=${window.innerWidth} innerHeight=${window.innerHeight}`)
console.log(`stageConfig designWidth=${stageConfig.designWidth} designWidth=${stageConfig.designHeight}`)
// if (window.innerWidth > window.innerHeight) {
// stageConfig.designWidth = 1920
// stageConfig.designHeight = 1080
// stageConfig.scaleMode = "fixedwidth"
// config.H_SCREEN = true
// }
// else {
// stageConfig.designWidth = 1080
// stageConfig.designHeight = 1920
// stageConfig.scaleMode = "fixedheight"
// config.H_SCREEN = false
// }
// console.log(`横屏=${config.H_SCREEN}`)
if (window.innerWidth > window.innerHeight) {
stageConfig.designWidth = 1920
stageConfig.designHeight = 1080
stageConfig.scaleMode = "fixedwidth"
config.H_SCREEN = true
}
else {
stageConfig.designWidth = 1080
stageConfig.designHeight = 1920
stageConfig.scaleMode = "fixedheight"
config.H_SCREEN = false
}
console.log(`横屏=${config.H_SCREEN}`)
})
export async function main() {

View File

@@ -3,6 +3,7 @@ import { config } from "./config";
export const respath = {
home_ui_res: "resources/Home.lh",
topbar_ui_res: "resources/TopBar.lh",
dc_ui_res: "resources/DailyChallenge.lh",
trophy_claim_ui_res: "resources/TrophyClaim.lh",
trophy_show_ui_res: "resources/TrophyShow.lh",

View File

@@ -1,10 +1,11 @@
import { respath } from "../constants/respath"
import { StorageManager } from "./StorageManager"
import { Stage } from "../views/Stage"
import { DailyChallenge } from "../views/DailyChallenge"
import { DailyChallenge } from "../views/dc/DailyChallenge"
import { TrophyRecord } from "../types/global"
import { TrophyClaim } from "../views/TrophyClaim"
import { TrophyShow } from "../views/TrophyShow"
import { TrophyClaim } from "../views/dc/TrophyClaim"
import { TrophyShow } from "../views/dc/TrophyShow"
import { config } from "../constants/config"
const { regClass, property } = Laya
@@ -19,8 +20,13 @@ export class UIManager extends Laya.Script {
}
onStart(): void {
if (config.H_SCREEN) {
this.loadTopBarUI()
}
else {
this.loadHomeUI()
}
}
public static getInstance(): UIManager {
return UIManager._instance
@@ -40,6 +46,13 @@ export class UIManager extends Laya.Script {
})
}
public loadTopBarUI(): void {
Laya.loader.load(respath.topbar_ui_res).then((go)=>{
var prefab = go.create()
this.getUIRoot().addChild(prefab)
})
}
public loadDCUI(): void {
Laya.loader.load(respath.dc_ui_res).then((go)=>{
var prefab = go.create()

View File

@@ -97,11 +97,15 @@ export class Stage extends Laya.Script {
}
}
for (var i=0; i<this.obj_candys.numChildren; i++) {
var candy = this.obj_candys.getChildAt(i).getComponent(Candy);
hbox = this.obj_candys.getChildAt(i)
l_hbox = this.obj_candy_labels.getChildAt(i)
for (var j=0; j<hbox.numChildren; j++) {
var candy = hbox.getChildAt(j).getComponent(Candy);
this.candys.push(candy);
var box = this.obj_candy_labels.getChildAt(i) as Laya.Box
var box = l_hbox.getChildAt(j) as Laya.Box
candy.onInit(box, this, this.onClickCandy)
}
}
this.btn_undo.on(Laya.Event.CLICK, this, this.onClickUndo)
this.btn_erase.on(Laya.Event.CLICK, this, this.onClickErase)

103
src/views/TopBar.ts Normal file
View File

@@ -0,0 +1,103 @@
import { config } from "../constants/config";
import { StorageManager } from "../models/StorageManager";
import { UIManager } from "../models/UIManager";
import { CommonData } from "./common/CommonData";
const { regClass, property } = Laya;
@regClass()
export class TopBar extends Laya.Script {
declare owner : Laya.Box;
@property(Laya.Box)
public btn_classic: Laya.Box
@property(Laya.Sprite)
public sprite_classic: Laya.Sprite
@property(Laya.Label)
public label_classic: Laya.Label
@property(Laya.Box)
public btn_dc: Laya.Box
@property(Laya.Sprite)
public sprite_dc: Laya.Sprite
@property(Laya.Label)
public label_dc: Laya.Label
private isClassic: boolean = true
@property(Laya.Box)
public obj_items: Laya.Box
private items: Map<string, Laya.Label> = new Map()
onStart(): void {
this.btn_classic.on(Laya.Event.CLICK, this, ()=>{
if (this.isClassic == false) {
this.isClassic = true
this.setLeftTab()
}
})
this.btn_dc.on(Laya.Event.CLICK, this, ()=>{
if (this.isClassic) {
this.isClassic = false
this.setLeftTab()
}
})
this.setLeftTab()
for (var i=0; i<this.obj_items.numChildren; i++) {
var obj = this.obj_items.getChildAt(i)
var value = config.DIFFICULTY_LIST[i]
var label = obj.getChildByName("Label") as Laya.Label
label.text = value
this.items.set(value, label)
var common = obj.getComponent(CommonData)
common.strValue = value
obj.on(Laya.Event.CLICK, this, (evt: Laya.Event)=>{
var common = evt.target.getComponent(CommonData)
var difficulty = Laya.LocalStorage.getItem("difficulty")
if (common.strValue != difficulty) {
this.setDifficulty(common.strValue)
Laya.LocalStorage.setItem("difficulty", common.strValue)//记录横屏模式用户选择的难度
StorageManager.getInstance().cleanStage()
StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, difficulty, difficulty)
UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID)
}
})
}
//如果是第一次以横屏启动游戏需要创建经典关卡
var difficulty = Laya.LocalStorage.getItem("difficulty")//读取用户上次选择的难度
if (!difficulty || difficulty.length<=0) {
difficulty = config.DIFFICULTY_TYPE.Easy
Laya.LocalStorage.setItem("difficulty", difficulty)
}
var doStage = StorageManager.getInstance().loadStage(config.DEFAULT_STAGE_ID)
if (!doStage) {
StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, difficulty, difficulty)
}
this.setDifficulty(difficulty)
}
setLeftTab(): void {
this.sprite_classic.alpha = this.isClassic ? 1 : 0.1
this.label_classic.color = this.isClassic ? "#ffffff" : "#0e2a53"
this.sprite_dc.alpha = this.isClassic ? 0.1 : 1
this.label_dc.color = this.isClassic ? "#0e2a53" : "#ffffff"
if (this.isClassic) {
UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID)
}
}
setDifficulty(difficulty: string): void {
this.items.forEach((label: Laya.Label, key: string)=>{
label.color = "#0e2a53"
})
var label = this.items.get(difficulty)
label.color = "#1d5cdc"
}
}

3
src/views/TopBar.ts.meta Normal file
View File

@@ -0,0 +1,3 @@
{
"uuid": "cadd567d-5099-49b9-a9b3-b7c404d5fe1b"
}

View File

@@ -1,11 +1,10 @@
import { config } from "../constants/config";
import { Utility_ConvertSecondToString } from "../utils/utility";
import { StorageManager } from "../models/StorageManager";
import { config } from "../../constants/config";
import { Utility_ConvertSecondToString } from "../../utils/utility";
import { StorageManager } from "../../models/StorageManager";
import { CalendarUnit } from "./CalendarUnit";
import { LevelManager } from "../models/LevelManager";
import { UIManager } from "../models/UIManager";
import { respath } from "../constants/respath";
import { MONTH_LIST } from "../models/DCManager";
import { UIManager } from "../../models/UIManager";
import { respath } from "../../constants/respath";
import { MONTH_LIST } from "../../models/DCManager";
const { regClass, property } = Laya;

View File

@@ -1,6 +1,6 @@
import { config } from "../constants/config";
import { MONTH_LIST } from "../models/DCManager";
import { TrophyRecord } from "../types/global";
import { config } from "../../constants/config";
import { MONTH_LIST } from "../../models/DCManager";
import { TrophyRecord } from "../../types/global";
const { regClass, property } = Laya;

View File

@@ -2,8 +2,8 @@
import { respath } from "../constants/respath";
import { MONTH_LIST } from "../models/DCManager";
import { respath } from "../../constants/respath";
import { MONTH_LIST } from "../../models/DCManager";
import { TrophyUnit } from "./TrophyUnit";
const { regClass, property } = Laya;

View File

@@ -1,7 +1,7 @@
import { config } from "../constants/config";
import { MONTH_LIST } from "../models/DCManager";
import { TrophyRecord } from "../types/global";
import { config } from "../../constants/config";
import { MONTH_LIST } from "../../models/DCManager";
import { TrophyRecord } from "../../types/global";
const { regClass, property } = Laya;

View File

@@ -1,7 +1,7 @@
import { config } from "../constants/config";
import { respath } from "../constants/respath";
import { StorageManager } from "../models/StorageManager";
import { UIManager } from "../models/UIManager";
import { config } from "../../constants/config";
import { respath } from "../../constants/respath";
import { StorageManager } from "../../models/StorageManager";
import { UIManager } from "../../models/UIManager";
const { regClass, property } = Laya;