加分动画
This commit is contained in:
@@ -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,28 +15,24 @@
|
||||
},
|
||||
{
|
||||
"_$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,
|
||||
"height": 60,
|
||||
"_$child": [
|
||||
{
|
||||
"_$id": "7popbrt7",
|
||||
"_$id": "2eibhgkk",
|
||||
"_$type": "Label",
|
||||
"name": "Label",
|
||||
"x": 75,
|
||||
"y": 30,
|
||||
"width": 150,
|
||||
"x": 55,
|
||||
"y": -42,
|
||||
"width": 200,
|
||||
"height": 60,
|
||||
"anchorX": 0.5,
|
||||
"anchorY": 0.5,
|
||||
"centerX": -3,
|
||||
"text": "+150",
|
||||
"font": "res://7322bbf9-175b-4a25-a0d7-72d369894de2",
|
||||
"fontSize": 60,
|
||||
@@ -51,6 +45,4 @@
|
||||
"strokeColor": "rgba(255, 255, 255, 1)"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"uuid": "a07d56a7-b6d8-40b9-97c2-6c2b0e294ff1"
|
||||
"uuid": "cc3e3def-73ab-4c93-91ca-15fe9360c857"
|
||||
}
|
||||
50
assets/resources/ScoreAdd_H.lh
Normal file
50
assets/resources/ScoreAdd_H.lh
Normal file
@@ -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)"
|
||||
}
|
||||
]
|
||||
}
|
||||
3
assets/resources/ScoreAdd_H.lh.meta
Normal file
3
assets/resources/ScoreAdd_H.lh.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"uuid": "79c5a2f1-0c0d-484c-ad6f-f31b3f3fcbd2"
|
||||
}
|
||||
@@ -10,5 +10,6 @@
|
||||
},
|
||||
"splash": {
|
||||
"fit": "center"
|
||||
}
|
||||
},
|
||||
"stat": true
|
||||
}
|
||||
@@ -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",
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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<blocks.length; i++) {
|
||||
score += blocks[i].get_score()
|
||||
}
|
||||
this.label_score.text = `Score: ${score}`
|
||||
return score
|
||||
if (this.score_current != score) {//分数发生变化
|
||||
this.score_current = score
|
||||
this.score_step = Math.ceil((this.score_current - this.score_last)/24)
|
||||
if (this.score_current > 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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user