From b6126cebad738669c900e9461851afb8ba833bf3 Mon Sep 17 00:00:00 2001 From: yangwen Date: Tue, 27 May 2025 14:59:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=88=86=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/resources/ScoreAdd.lh | 60 +++++++++++++---------------- assets/resources/ScoreAdd.lh.meta | 2 +- assets/resources/ScoreAdd_H.lh | 50 ++++++++++++++++++++++++ assets/resources/ScoreAdd_H.lh.meta | 3 ++ settings/PlayerSettings.json | 3 +- src/constants/respath.ts | 5 ++- src/views/Block.ts | 2 +- src/views/ScoreAdd.ts | 40 ++++++++++++++++--- src/views/Stage.ts | 45 +++++++++++++++++++--- src/views/common/AutoDestroy.ts | 2 +- src/views/common/GUITips.ts | 8 ++-- 11 files changed, 167 insertions(+), 53 deletions(-) create mode 100644 assets/resources/ScoreAdd_H.lh create mode 100644 assets/resources/ScoreAdd_H.lh.meta diff --git a/assets/resources/ScoreAdd.lh b/assets/resources/ScoreAdd.lh index 9f8272b..4b1b6bf 100644 --- a/assets/resources/ScoreAdd.lh +++ b/assets/resources/ScoreAdd.lh @@ -1,12 +1,10 @@ { "_$ver": 1, - "_$id": "pl8y75ht", + "_$id": "w86l3m5x", "_$type": "Box", "name": "ScoreAdd", - "x": 885, - "y": 510, - "width": 150, - "height": 60, + "width": 116, + "height": 116, "centerX": 0, "centerY": 0, "_$comp": [ @@ -17,40 +15,34 @@ }, { "_$type": "c910a064-d127-442e-a884-b5289c488647", - "scriptPath": "../src/views/ScoreAdd.ts" + "scriptPath": "../src/views/ScoreAdd.ts", + "label": { + "_$ref": "2eibhgkk" + } } ], "_$child": [ { - "_$id": "chd952dx", - "_$type": "Box", - "name": "offset", - "y": -60, - "width": 150, + "_$id": "2eibhgkk", + "_$type": "Label", + "name": "Label", + "x": 55, + "y": -42, + "width": 200, "height": 60, - "_$child": [ - { - "_$id": "7popbrt7", - "_$type": "Label", - "name": "Label", - "x": 75, - "y": 30, - "width": 150, - "height": 60, - "anchorX": 0.5, - "anchorY": 0.5, - "text": "+150", - "font": "res://7322bbf9-175b-4a25-a0d7-72d369894de2", - "fontSize": 60, - "color": "rgba(29, 92, 220, 1)", - "bold": true, - "align": "center", - "valign": "middle", - "padding": "0,0,0,0", - "stroke": 16, - "strokeColor": "rgba(255, 255, 255, 1)" - } - ] + "anchorX": 0.5, + "anchorY": 0.5, + "centerX": -3, + "text": "+150", + "font": "res://7322bbf9-175b-4a25-a0d7-72d369894de2", + "fontSize": 60, + "color": "rgba(29, 92, 220, 1)", + "bold": true, + "align": "center", + "valign": "middle", + "padding": "0,0,0,0", + "stroke": 16, + "strokeColor": "rgba(255, 255, 255, 1)" } ] } \ No newline at end of file diff --git a/assets/resources/ScoreAdd.lh.meta b/assets/resources/ScoreAdd.lh.meta index cc84b1e..53954df 100644 --- a/assets/resources/ScoreAdd.lh.meta +++ b/assets/resources/ScoreAdd.lh.meta @@ -1,3 +1,3 @@ { - "uuid": "a07d56a7-b6d8-40b9-97c2-6c2b0e294ff1" + "uuid": "cc3e3def-73ab-4c93-91ca-15fe9360c857" } \ No newline at end of file diff --git a/assets/resources/ScoreAdd_H.lh b/assets/resources/ScoreAdd_H.lh new file mode 100644 index 0000000..533d06f --- /dev/null +++ b/assets/resources/ScoreAdd_H.lh @@ -0,0 +1,50 @@ +{ + "_$ver": 1, + "_$id": "r3lhk79l", + "_$type": "Box", + "name": "ScoreAdd_H", + "x": 3, + "y": 3, + "width": 90, + "height": 90, + "centerX": 0, + "centerY": 0, + "_$comp": [ + { + "_$type": "bdb0e671-99fa-47a5-9101-7ec008b1d25d", + "scriptPath": "../src/views/common/AutoDestroy.ts", + "lifeTime": 2 + }, + { + "_$type": "c910a064-d127-442e-a884-b5289c488647", + "scriptPath": "../src/views/ScoreAdd.ts", + "label": { + "_$ref": "4337viuh" + } + } + ], + "_$child": [ + { + "_$id": "4337viuh", + "_$type": "Label", + "name": "Label", + "x": 42, + "y": -42, + "width": 200, + "height": 45, + "anchorX": 0.5, + "anchorY": 0.5, + "centerX": -3, + "text": "+150", + "font": "res://7322bbf9-175b-4a25-a0d7-72d369894de2", + "fontSize": 45, + "color": "rgba(29, 92, 220, 1)", + "bold": true, + "align": "center", + "valign": "middle", + "padding": "0,0,0,0", + "stroke": 16, + "strokeColor": "rgba(255, 255, 255, 1)" + } + ] +} \ No newline at end of file diff --git a/assets/resources/ScoreAdd_H.lh.meta b/assets/resources/ScoreAdd_H.lh.meta new file mode 100644 index 0000000..31227df --- /dev/null +++ b/assets/resources/ScoreAdd_H.lh.meta @@ -0,0 +1,3 @@ +{ + "uuid": "79c5a2f1-0c0d-484c-ad6f-f31b3f3fcbd2" +} \ No newline at end of file diff --git a/settings/PlayerSettings.json b/settings/PlayerSettings.json index 8999245..664db4d 100644 --- a/settings/PlayerSettings.json +++ b/settings/PlayerSettings.json @@ -10,5 +10,6 @@ }, "splash": { "fit": "center" - } + }, + "stat": true } \ No newline at end of file diff --git a/src/constants/respath.ts b/src/constants/respath.ts index 85adc53..3d6d25d 100644 --- a/src/constants/respath.ts +++ b/src/constants/respath.ts @@ -24,7 +24,10 @@ export const respath = { } }, - score_add_ui_res: "resources/ScoreAdd.lh", + score_add_ui_res: function func(): string { + return config.H_SCREEN ? "resources/ScoreAdd_H.lh" : "resources/ScoreAdd.lh" + }, + common_tips_ui_res: "resources/CommonTips.lh", difficulty_ui_res: "resources/Difficulty.lh", diff --git a/src/views/Block.ts b/src/views/Block.ts index 4fabe7c..90bd08e 100644 --- a/src/views/Block.ts +++ b/src/views/Block.ts @@ -127,7 +127,7 @@ export class Block extends Laya.Script { if (this.data.get_checked()) { this.data.set_score(score) if (score > 0) - G_ShowScoreTips(score.toString(), this.label_show) + G_ShowScoreTips(score.toString(), this.label_show.parent) } else { if (this.data.get_score() != 0) diff --git a/src/views/ScoreAdd.ts b/src/views/ScoreAdd.ts index b171999..3248e8d 100644 --- a/src/views/ScoreAdd.ts +++ b/src/views/ScoreAdd.ts @@ -1,14 +1,44 @@ +import { config } from "../constants/config"; +import { AutoDestroy } from "./common/AutoDestroy"; + const { regClass, property } = Laya; @regClass() export class ScoreAdd extends Laya.Script { declare owner : Laya.Box; - //组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次 + @property(Laya.Label) + public label: Laya.Label + onAwake(): void { - var offset = this.owner.getChildByName("offset") - Laya.Tween.to(offset, {y:-200}, 1000, Laya.Ease.strongIn, null, 500) - var Label = offset.getChildByName("Label") - Laya.Tween.to(Label, {scaleX:1.5, scaleY:1.5}, 500) + this.label.scaleX = 0 + this.label.skewY = 0 + + var d = this.owner.getComponent(AutoDestroy) + d.lifeTime = 2 } + + onStart(): void { + + var wait = 0 + + var duration = 300 + Laya.Tween.to(this.label, {scaleX: 1, scaleY: 1}, duration, Laya.Ease.strongIn, null, wait) + wait += duration + + duration = 300 + Laya.Tween.to(this.label, {y:-102}, duration, Laya.Ease.strongIn, null, wait) + wait += duration + + duration = 300 + Laya.Tween.to(this.label, {alpha:0}, duration, Laya.Ease.strongIn, null, wait) + wait += duration + + } + + public onSetText(text: string): void { + this.label.text = text + } + + } \ No newline at end of file diff --git a/src/views/Stage.ts b/src/views/Stage.ts index 4a7776c..388182e 100644 --- a/src/views/Stage.ts +++ b/src/views/Stage.ts @@ -25,6 +25,10 @@ export class Stage extends Laya.Script { public btn_pause: Laya.Button @property(Laya.Label) public label_score: Laya.Label; + private score_last: number + private score_current: number + private score_step: number + private score_animation_wait_frame = 0 @property(Laya.Label) public label_mistake: Laya.Label; @property(Laya.Label) @@ -162,7 +166,12 @@ export class Stage extends Laya.Script { this.btn_new.visible = this.data.get_stageType() == config.STAGE_TYPE.MAIN } + this.score_last = 0 + this.score_current = 0 this.onUpdateScore() + this.score_last = this.score_current + this.label_score.text = `Score: ${this.score_last}` + this.label_name.text = this.data.get_stageName() if (this.data.get_stageType() == config.STAGE_TYPE.MAIN && config.H_SCREEN) this.label_name.text = "" @@ -197,14 +206,41 @@ export class Stage extends Laya.Script { this.onApplyBlock(this.selectedBlock) } - onUpdateScore(): number { + onUpdateScore(): void { var score = 0 var blocks = this.data.get_blocks() for (var i=0; i this.score_last) + this.score_animation_wait_frame = 54 + else + this.score_animation_wait_frame = 0 + this.data.set_score(score) + } + } + + onLateUpdate(): void { + this.score_animation_wait_frame -- + if (this.score_animation_wait_frame < 0) + this.score_animation_wait_frame = 0 + if (this.score_animation_wait_frame <= 0) { + if (this.score_current != this.score_last) { + if (this.score_current > this.score_last) { + this.score_last += this.score_step + if (this.score_last > this.score_current) + this.score_last = this.score_current + this.label_score.text = `Score: ${this.score_last}` + } + else { + this.label_score.text = `Score: ${this.score_current}` + this.score_last = this.score_current + } + } + } } onUpdateMistake(): void { @@ -408,7 +444,7 @@ export class Stage extends Laya.Script { blockScore = Utility_CalculateScore(this.data.get_difficulty(), duration) } var b = this.selectedBlock.setShowNumber(showNumber, blockScore) - var score = this.onUpdateScore() + this.onUpdateScore() this.onSetBlock(this.selectedBlock, true) if (b) { this.data.set_last_hit_time(this.data.get_duration()) @@ -429,7 +465,6 @@ export class Stage extends Laya.Script { if (this.getIsComplete()) { console.log("完成关卡", finished, all, progress) this.paused = true - this.data.set_score(score) if (this.data.get_stageType() == config.STAGE_TYPE.MAIN) {//主线关卡更新难度进度 user.update_progress(this.data.get_difficulty(), this.data.get_stageIndex()+1) UIManager.getInstance().loadGameDoneUI(true, this.data) diff --git a/src/views/common/AutoDestroy.ts b/src/views/common/AutoDestroy.ts index d7b3ab4..c1162a5 100644 --- a/src/views/common/AutoDestroy.ts +++ b/src/views/common/AutoDestroy.ts @@ -8,7 +8,7 @@ export class AutoDestroy extends Laya.Script { public lifeTime: number = 1; //组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次 - onAwake(): void { + onStart(): void { if (this.lifeTime < 1) { this.lifeTime = 1 } diff --git a/src/views/common/GUITips.ts b/src/views/common/GUITips.ts index 18255f8..4acf3e4 100644 --- a/src/views/common/GUITips.ts +++ b/src/views/common/GUITips.ts @@ -1,10 +1,10 @@ import { respath } from "../../constants/respath" +import { ScoreAdd } from "../ScoreAdd" export function G_ShowScoreTips(text: string, parent: any): void { - Laya.loader.load(respath.score_add_ui_res).then((go)=>{ + Laya.loader.load(respath.score_add_ui_res()).then((go)=>{ var prefab = go.create() - var obj = parent.addChild(prefab) - var Label = obj.getChildByName("offset").getChildByName("Label") as Laya.Label - Label.text = text + var score = parent.addChild(prefab).getComponent(ScoreAdd) + score.onSetText(text) }) }