设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 36|回复: 0
打印 上一主题 下一主题

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

[复制链接]

Lv1.梦旅人

梦石
0
星屑
51
在线时间
6 小时
注册时间
2025-4-29
帖子
6
跳转到指定楼层
1
发表于 昨天 20:18 | 只看该作者 |只看大图 回帖奖励 |正序浏览 |阅读模式

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

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

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

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

效果图是这样:





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);
        }
    };
})();
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2025-5-12 18:26

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表