Project1
标题:
自定义鼠标 可判断点击状态
[打印本页]
作者:
3eki
时间:
2025-5-11 20:18
标题:
自定义鼠标 可判断点击状态
找了很久没有找到类似的插件,自己整了一个。
可以自定义鼠标,鼠标点击的时候可以切换成其他动效。
效果图是这样:
copy_594CA638-3C4D-4684-9DCD-B95600D17575.GIF
(670.72 KB, 下载次数: 25)
下载附件
保存到相册
2025-5-11 20:17 上传
url:https://github.com/SekiShiyo/RMMZ/blob/main/MousePointer
代码不知道咋贴,直接paste上来。
/*:
* @target MZ
* @plugindesc v1.0 自定义点击状态鼠标指针(点击检测)
* @author SekiShiyo
*
*
* @param defaultCursor
* @text 默认光标图片
* @type file
* @dir img/system
* @desc 默认状态下显示的光标图像(不含扩展名)
*
* @param clickCursor
* @text 点击时光标图片
* @type file
* @dir img/system
* @desc 鼠标点击时显示的光标图像(不含扩展名)
*
* @help
* - 将两张图放入 img/system 文件夹;
* - 默认使用 defaultCursor 图像;
* - 鼠标按下时切换为 clickCursor 图像;
* - 自动适配 MZ 场景;
* - 不使用 PIXI Sprite,不会被遮挡。
*/
(() => {
const params = PluginManager.parameters("MousePointer") || {};
const defaultCursor = params["defaultCursor"] || "Cursor1";
const clickCursor = params["clickCursor"] || "Cursor2";
let isPressed = false;
// 设置光标图像(使用 CSS)
function updateCursorImage(imageName) {
const url = `url("img/system/${imageName}.png"), auto`;
document.body.style.cursor = url;
}
// 初始设置
window.addEventListener("load", () => {
updateCursorImage(defaultCursor);
});
// 在每帧检测按压状态
const _SceneManager_updateMain = SceneManager.updateMain;
SceneManager.updateMain = function() {
_SceneManager_updateMain.call(this);
const nowPressed = TouchInput.isPressed();
if (nowPressed !== isPressed) {
isPressed = nowPressed;
updateCursorImage(isPressed ? clickCursor : defaultCursor);
}
};
})();
作者:
lurenjia2333
时间:
2025-5-25 16:06
感谢分享!
作者:
写给妖精的情诗
时间:
2025-5-25 18:43
https://developer.rpgmakerweb.com/rpg-maker-mz/Input.html
上面这个 RPG Maker MZ API 文档 就有啊。
但是你这个更改光标图像是没有的。
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1