mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2025-10-09 08:36:14 +00:00
heal anim
This commit is contained in:
@@ -34,7 +34,7 @@ export class Player extends Component {
|
||||
this.speed = data.speed;
|
||||
|
||||
this.weapon.init(data.strikeDelay, data.damage);
|
||||
this.health.HealthPointsChangeEvent.on(this.animateHurt, this);
|
||||
this.health.HealthPointsChangeEvent.on(this.animateHpChange, this);
|
||||
this.playerUI.init(this.health);
|
||||
}
|
||||
|
||||
@@ -94,8 +94,13 @@ export class Player extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
private async animateHurt(): Promise<void> {
|
||||
this.sprite.color = Color.RED;
|
||||
private async animateHpChange(hpChange: number): Promise<void> {
|
||||
if (hpChange < 0) {
|
||||
this.sprite.color = Color.RED;
|
||||
} else {
|
||||
this.sprite.color = Color.GREEN;
|
||||
}
|
||||
|
||||
await delay(100);
|
||||
this.sprite.color = Color.WHITE;
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { Component, ProgressBar, _decorator } from "cc";
|
||||
import { UnitHealth } from "../UnitHealth";
|
||||
import { UnitHealth } from "../../UnitHealth";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("PlayerHealthUI")
|
||||
|
Reference in New Issue
Block a user