加分动画
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user