69 lines
1.5 KiB
Plaintext
69 lines
1.5 KiB
Plaintext
/*
|
|
文件名:CursorObject.nut
|
|
路径:BaseClass/CursorObject/CursorObject.nut
|
|
创建日期:2024-05-06 15:29
|
|
文件用途:光标指针
|
|
*/
|
|
class CL_Cursor {
|
|
|
|
//光标的精灵对象
|
|
CursorSprite = null;
|
|
//光标的精灵帧Map
|
|
CursorSpriteFrame = null;
|
|
//光标的当前Task
|
|
Task = 0;
|
|
|
|
CursorImgPath = "sprite/interface/newstyle/windows/cursor.img";
|
|
|
|
|
|
constructor() {
|
|
CursorSpriteFrame = {};
|
|
LoadTaskSpriteFrame();
|
|
|
|
CursorSprite = CL_SpriteObject();
|
|
SetTask(Task);
|
|
}
|
|
|
|
//加载工作样式精灵帧
|
|
function LoadTaskSpriteFrame() {
|
|
for (local i = 0; i< 186; i++) {
|
|
CursorSpriteFrame[i] <- CL_SpriteFrameObject(CursorImgPath, i);
|
|
}
|
|
}
|
|
|
|
//设置光标工作样式
|
|
function SetTask(Idx) {
|
|
Task = Idx;
|
|
CursorSprite.SetFrame(CursorSpriteFrame[Idx]);
|
|
}
|
|
|
|
|
|
//更新
|
|
function OnUpdate(dt) {
|
|
//没有其他任务模式时
|
|
if (Task <= 1) {
|
|
//左键按下 和 弹起
|
|
if (Input_IsDown(MouseButton.Left, 0)) {
|
|
SetTask(1);
|
|
} else {
|
|
SetTask(0);
|
|
}
|
|
}
|
|
}
|
|
|
|
//获取光标精灵C指针
|
|
function GetCPtr() {
|
|
return CursorSprite.C_Object;
|
|
}
|
|
}
|
|
|
|
//初始化光标
|
|
function InitCursor() {
|
|
local Obj = CL_Cursor();
|
|
getroottable().IMouse <- Obj;
|
|
return Obj.GetCPtr();
|
|
}
|
|
//更新光标
|
|
function UpdateCursor(dt) {
|
|
getroottable().IMouse.OnUpdate(dt);
|
|
} |