import { _decorator, Component, Node, sp, UITransform, Vec2, Vec3 ,Animation, Color, tween} from 'cc'; import { BattleNodeBase } from './BattleNodeBase'; import { RenderPriority } from '../data/BattleEnum'; const { ccclass, property } = _decorator; // 子弹基类 @ccclass('Bullet') export class Bullet extends BattleNodeBase { speedVector: Vec2 = new Vec2(0, 0); bStand: boolean = false; target: Node = null; dieCallback: Function = null; protected onLoad(): void { this.priority = RenderPriority.Bullet; } start() { } //用自定义更新,不用系统更新 battleUpdate(deltaTime: number) { this.node.position = new Vec3(this.node.position.x+this.speedVector.x*deltaTime,this.node.position.y+this.speedVector.y*deltaTime,0) } resetData(typeID:number,ID:number,pos:Vec3,life:number,lifeMax:number) { this.typeID = typeID; this.ID = ID; this.node.position = pos this.bStand = false; this.dieCallback = null; } startMove(animationName:string){ this.node.active = true; // this.modelSpine.setAnimation(0, 'idle', true); } stand() { this.bStand = true; } clearData() { this.node.active = false } die(callback?:Function) { this.dieCallback = callback; tween(this.node).delay(0.5).call(() => { this.node.active = false this.dieCallback && this.dieCallback() }).start() } actionComplete(trackEntry:sp.spine.TrackEntry){ // console.log("动作完成:",trackEntry.animation.name,this._posID) // if (trackEntry.animation.name && trackEntry.animation.name.includes("hurt")) { // this._bHurtAnimation = false; // this.modelSpine.addAnimation(0, 'idle', true); // this.modelSpine.color = Color.WHITE; // } } }