鼠标框架完成 窗口事件框架完成
This commit is contained in:
20
UI/Windows/HUD/Window_hud.nut
Normal file
20
UI/Windows/HUD/Window_hud.nut
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
文件名:Window_hud.nut
|
||||
路径:UI/Windows/HUD/Window_hud.nut
|
||||
创建日期:2025-10-19 20:36
|
||||
文件用途:
|
||||
*/
|
||||
|
||||
class Window_hud extends GameWindow {
|
||||
constructor(Name, gX, gY, gWidth, gHeight, gTitleHeight) {
|
||||
base.constructor(Name, gX, gY, gWidth, gHeight, gTitleHeight);
|
||||
|
||||
InitSprite();
|
||||
}
|
||||
|
||||
function InitSprite() {
|
||||
local Sp = Sprite("sprite/interface2/hud/hud.img", 0);
|
||||
Sp.SetPos((1280 - 403) / 2, 720 - 75);
|
||||
AddChild(Sp);
|
||||
}
|
||||
}
|
||||
75
UI/Windows/System/Cursor.nut
Normal file
75
UI/Windows/System/Cursor.nut
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
文件名:Cursor.nut
|
||||
路径:UI/Windows/System/Cursor.nut
|
||||
创建日期:2025-10-21 18:46
|
||||
文件用途:
|
||||
*/
|
||||
|
||||
class Game_Cursor extends GameWindow {
|
||||
//鼠标精灵数组
|
||||
MouseSprite = null;
|
||||
//当前鼠标工作ID
|
||||
CurrentMouseTaskId = 0;
|
||||
|
||||
//鼠标X坐标
|
||||
MouseX = 0;
|
||||
//鼠标Y坐标
|
||||
MouseY = 0;
|
||||
|
||||
constructor() {
|
||||
if (getroottable().rawin("__Game_Cursor__")) {
|
||||
// 防止重复实例化
|
||||
throw "Game_Cursor 不能重复实例化!";
|
||||
}
|
||||
base.constructor("系统鼠标", 0, 0, 1280, 720, 0);
|
||||
|
||||
Init();
|
||||
//设置鼠标的层级最高
|
||||
this.SetZOrder(10000000);
|
||||
_SYS_UI_SCENE_Instance_.AddChild(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 静态方法:获取唯一实例
|
||||
* @function
|
||||
* @returns {Game_Cursor}
|
||||
*/
|
||||
function GetInstance() {
|
||||
if (!getroottable().rawin("__Game_Cursor__")) {
|
||||
// 首次调用时创建实例
|
||||
getroottable()["__Game_Cursor__"] <- Game_Cursor();
|
||||
}
|
||||
return getroottable()["__Game_Cursor__"];
|
||||
}
|
||||
|
||||
function Init() {
|
||||
MouseSprite = [];
|
||||
for (local i = 0; i < 254; i++) {
|
||||
//初始化鼠标精灵
|
||||
local Buffer = Sprite("sprite/interface/newstyle/windows/cursor.img", i);
|
||||
MouseSprite.push(Buffer);
|
||||
}
|
||||
SetNormalTask(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置鼠标的普通任务
|
||||
* @function
|
||||
* @returns {void}
|
||||
*/
|
||||
function SetNormalTask(TaskId) {
|
||||
RemoveChild(MouseSprite[CurrentMouseTaskId]);
|
||||
CurrentMouseTaskId = TaskId;
|
||||
AddChild(MouseSprite[CurrentMouseTaskId]);
|
||||
MouseSprite[CurrentMouseTaskId].SetPos(MouseX, MouseY);
|
||||
}
|
||||
|
||||
//事件
|
||||
function Event(EventType, EventData) {
|
||||
if (EventType == UI_EVENT.MOUSEMOTION) {
|
||||
MouseX = EventData[0];
|
||||
MouseY = EventData[1];
|
||||
MouseSprite[CurrentMouseTaskId].SetPos(MouseX, MouseY);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user