//声明一个血条
protected m_hpprogressBar:Laya.ProgressBar=new Laya.ProgressBar();
//初始化血条
InitHPProgressBar()
{
Laya.stage.addChild(this.m_hpprogressBar);
this.m_hpprogressBar.skin="ui/progress.png";
this.m_hpprogressBar.anchorX=0.5;
this.m_hpprogressBar.anchorY=0.5;
this.m_hpprogressBar.width = 100;
this.m_hpprogressBar.value=1;
this.m_hpprogressBar.sizeGrid = "5,5,5,5";
let camera=GameManager.GetInstance().CurrentCamera;
this.m_hpprogressBar.visible=false;
Laya.stage.addChild(this.m_hpprogressBar);
}
//更新血条位置
UpdateHpPos(){
this.m_timer-=TimeTool.DeltaTime;
let camera=GameManager.GetInstance().CurrentCamera;
camera.viewport.project(this.MyTransform.position, camera.projectionViewMatrix, this.m_outHpProgressPos);
this.m_hpprogressBar.pos(this.m_outHpProgressPos.x / Laya.stage.clientScaleX, this.m_outHpProgressPos.y / Laya.stage.clientScaleY-60);
}
创作不易 点个赞哈