97 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
			
		
		
	
	
			97 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
| /*
 | |
| 文件名:IMouse.nut
 | |
| 路径:User/UI/Widget/IMouse.nut
 | |
| 创建日期:2024-12-18	14:03
 | |
| 文件用途:
 | |
| */
 | |
| class _IMouse_ extends _Yosin_Cursor {
 | |
| 
 | |
|     NormalC = null;
 | |
|     //普通状态0 //动态状态1
 | |
|     State = 0;
 | |
|     //当前帧数编号
 | |
|     Idx = 0;
 | |
|     //动态帧 当前帧数
 | |
|     ActiveCurrentFrame = 0;
 | |
|     //动态帧 总帧数
 | |
|     ActiveFrameCount = 0;
 | |
|     //动态帧 Timer
 | |
|     ActiveFrameTimer = 0;
 | |
| 
 | |
|     constructor() {
 | |
|         NormalC = [];
 | |
|         base.constructor();
 | |
|         getroottable().IMouse <- this;
 | |
| 
 | |
|         //关闭系统鼠标
 | |
|         Sq_ShowCursor(false);
 | |
| 
 | |
|         //调用父类初始化 将自己添加为UI层子对象
 | |
|         Init();
 | |
|         //初始化所有普通图标
 | |
|         InitSprite();
 | |
| 
 | |
|         //更换为0号指针
 | |
|         Change(0);
 | |
| 
 | |
|         //注册Proc
 | |
|         _Game_Logic_Func_._IMouse_Proc <- Proc.bindenv(this);
 | |
|     }
 | |
| 
 | |
|     //初始化普通鼠标指针
 | |
|     function InitSprite() {
 | |
|         for (local i = 0; i< 254; i++) {
 | |
|             local Sp = CL_SpriteFrameObject("sprite/interface/newstyle/windows/cursor.img", i);
 | |
|             NormalC.push(Sp);
 | |
|         }
 | |
|     }
 | |
|     //更换普通鼠标指针
 | |
|     function Change(Idx) {
 | |
|         State = 0;
 | |
|         this.Idx = Idx;
 | |
|         local Sp = NormalC[Idx];
 | |
|         base.Change(Sp);
 | |
|     }
 | |
| 
 | |
|     //更换动态鼠标指针
 | |
|     function ChangeActive(Idx, Count) {
 | |
|         State = 1;
 | |
|         this.Idx = Idx;
 | |
|         this.ActiveFrameCount = Count;
 | |
|         this.ActiveCurrentFrame = 0;
 | |
|     }
 | |
| 
 | |
|     function OnMouseProc(MousePos_X, MousePos_Y) {
 | |
| 
 | |
|     }
 | |
| 
 | |
|     //按下
 | |
|     function OnMouseLbDown(MousePos_X, MousePos_Y) {
 | |
|         //普通状态的点击效果
 | |
|         if (Idx == 0) {
 | |
|             Change(1);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     //抬起
 | |
|     function OnMouseLbUp(MousePos_X, MousePos_Y) {
 | |
|         //普通状态的点击效果
 | |
|         if (Idx == 1) {
 | |
|             Change(0);
 | |
|         }
 | |
|     }
 | |
| 
 | |
| 
 | |
|     function Proc(Dt, Listener) {
 | |
|         if (State == 1) {
 | |
|             ActiveFrameTimer += Dt;
 | |
|             if (ActiveFrameTimer >= 160) {
 | |
|                 ActiveFrameTimer = 0;
 | |
|                 ActiveCurrentFrame += 1;
 | |
|                 if (ActiveCurrentFrame >= ActiveFrameCount) ActiveCurrentFrame = 0;
 | |
|                 local Sp = NormalC[Idx + ActiveCurrentFrame];
 | |
|                 base.Change(Sp);
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| } |