#include "Cursor.h" #include "SquirrelClassEx.h" //设置鼠标逻辑 void SetCursorGameLogic() { WindowPtr window = Application::GetInstance().GetWindow(); int X = window->GetPosX(); int MaxX = window->GetWidth() + X; int Y = window->GetPosY(); int MaxY = window->GetHeight() + Y; POINT pt = { 0, 0 }; GetCursorPos(&pt); if (pt.x >= X && pt.x <= MaxX && pt.y >= Y && pt.y <= MaxY /*&& GetForegroundWindow() == window->GetHandle()*/) { ShowCursor(FALSE); } } Cursor::Cursor() { this->SetName("GameCursorObject"); this->Retain(); } void Cursor::OnUpdate(Duration dt) { static bool Init = false; if (!Init) { TexturePtr ImageBuf = SquirrelClassEx::GetTexturePtrByImg("sprite/interface/cursor.img",0); this->SetFrame(ImageBuf); Init = true; } ////获取输入 Input& input = Input::GetInstance(); ////设置"鼠标"对象坐标等于鼠标坐标 this->SetPosition(input.GetMousePos()); //std::cout << (int)GetCursor() << std::endl; //设置鼠标消失的逻辑 if ((int)GetCursor() == 65541) { SetCursorGameLogic(); this->SetVisible(true); } else { this->SetVisible(false); } }