85 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
		
		
			
		
	
	
			85 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
|  | /* | ||
|  | 文件名:Lenheart_Ani_Class.nut | ||
|  | 路径:Base/UI/Lenheart_Ani_Class.nut | ||
|  | 创建日期:2024-08-06	18:56 | ||
|  | 文件用途:Ani | ||
|  | */ | ||
|  | class Lenheart_Ani { | ||
|  | 
 | ||
|  |     X = 0; | ||
|  |     Y = 0; | ||
|  | 
 | ||
|  |     ImgPath = null; | ||
|  |     ImgFrame = null; | ||
|  | 
 | ||
|  | 
 | ||
|  |     //播放状态 | ||
|  |     State = 0; | ||
|  |     //循环 | ||
|  |     LoopFlag = true; | ||
|  | 
 | ||
|  |     //当前帧数 | ||
|  |     CurFrame = 0; | ||
|  |     //初始化时间 | ||
|  |     InitTime = 0; | ||
|  |     //Ani当前帧播放时间 | ||
|  |     PlayCurTime = 0; | ||
|  | 
 | ||
|  | 
 | ||
|  |     //img 路径  调用帧数组 | ||
|  |     constructor(path, frame, Pos) { | ||
|  |         ImgPath = ("Character/" + path + ".img").tolower(); | ||
|  |         ImgFrame = frame; | ||
|  |         InitTime = Clock(); | ||
|  |         State = 1; | ||
|  |         X = Pos[0]; | ||
|  |         Y = Pos[1]; | ||
|  |     } | ||
|  | 
 | ||
|  | 
 | ||
|  |     function Show(dt) { | ||
|  |         if (State == 1) { | ||
|  |             if (ImgFrame) { | ||
|  |                 local NowFrameObj = ImgFrame[CurFrame]; | ||
|  |                 PlayCurTime += dt; | ||
|  |                 L_sq_DrawImg(ImgPath, NowFrameObj.ImgIndex, NowFrameObj.Pos[0] + X, NowFrameObj.Pos[1] + Y); | ||
|  |                 if (PlayCurTime >= NowFrameObj.Delay) { | ||
|  |                     CurFrame++; | ||
|  |                     //播放完成 | ||
|  |                     if (CurFrame >= ImgFrame.len()) { | ||
|  |                         if (LoopFlag) CurFrame = 0; | ||
|  |                         else State = 0; | ||
|  |                     } | ||
|  |                     InitTime = Clock(); | ||
|  |                     PlayCurTime = 0; | ||
|  |                 } | ||
|  |             } | ||
|  |         } | ||
|  |     } | ||
|  | 
 | ||
|  |     function ShowEx(dt,gRgba,rate_x,rate_y) { | ||
|  |         if (State == 1) { | ||
|  |             if (ImgFrame) { | ||
|  |                 local NowFrameObj = ImgFrame[CurFrame]; | ||
|  |                 PlayCurTime += dt; | ||
|  |                 L_sq_DrawImg(ImgPath, NowFrameObj.ImgIndex, NowFrameObj.Pos[0] + X, NowFrameObj.Pos[1] + Y,1,gRgba,rate_x,rate_y); | ||
|  |                 if (PlayCurTime >= NowFrameObj.Delay) { | ||
|  |                     CurFrame++; | ||
|  |                     //播放完成 | ||
|  |                     if (CurFrame >= ImgFrame.len()) { | ||
|  |                         if (LoopFlag) CurFrame = 0; | ||
|  |                         else State = 0; | ||
|  |                     } | ||
|  |                     InitTime = Clock(); | ||
|  |                     PlayCurTime = 0; | ||
|  |                 } | ||
|  |             } | ||
|  |         } | ||
|  |     } | ||
|  | 
 | ||
|  |     function Reset()  | ||
|  |     { | ||
|  |         CurFrame = 0; | ||
|  |         State = 1; | ||
|  |     } | ||
|  | } |