查看: 1180|回复: 2

[原创发布] 自定义鼠标 可判断点击状态

[复制链接]
梦石
0
星屑
110
在线时间
11 小时
注册时间
2025-4-29
回帖
7
发表于 2025-5-11 20:18:08 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
找了很久没有找到类似的插件,自己整了一个。

可以自定义鼠标,鼠标点击的时候可以切换成其他动效。

效果图是这样:

copy_594CA638-3C4D-4684-9DCD-B95600D17575.GIF



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);
        }
    };
})();
梦石
0
星屑
210
在线时间
28 小时
注册时间
2024-2-5
回帖
3
发表于 2025-5-25 16:06:10 | 显示全部楼层
感谢分享!
回复

使用道具 举报

梦石
0
星屑
1518
在线时间
167 小时
注册时间
2025-2-15
回帖
67
发表于 2025-5-25 18:43:51 | 显示全部楼层
https://developer.rpgmakerweb.com/rpg-maker-mz/Input.html
上面这个 RPG Maker MZ API 文档 就有啊。
但是你这个更改光标图像是没有的。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部