Hurt.ts 840 B

12345678910111213141516171819202122232425262728
  1. import { _decorator, Component, easing, Label, Node, tween, Vec3 } from 'cc';
  2. import { BattleNodeBase } from './BattleNodeBase';
  3. import { RenderPriority } from '../data/BattleEnum';
  4. const { ccclass, property } = _decorator;
  5. //受伤扣血
  6. @ccclass('Hurt')
  7. export class Hurt extends BattleNodeBase {
  8. @property({ type: Label, tooltip: '血条' })
  9. label: Label = null;
  10. protected onLoad(): void {
  11. this.priority = RenderPriority.Life;
  12. }
  13. start() {
  14. }
  15. hurt(hurt:number,onComplete:Function){
  16. this.node.active = true;
  17. this.label.string = hurt.toFixed(0);
  18. this.label.node.qtJumpPosition(new Vec3(Math.random()*60-30, Math.random()*20+10, 0), 20, 1, 0.5,{onComplete : ()=>{
  19. this.node.active = false;
  20. onComplete&&onComplete()
  21. }}).start()
  22. }
  23. }