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

Project1

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

[交流讨论] 添加结束游戏的办法

[复制链接]

Lv1.梦旅人

梦石
0
星屑
17
在线时间
3 小时
注册时间
2024-7-31
帖子
5
跳转到指定楼层
1
发表于 2024-8-5 08:33:32 | 只看该作者 回帖奖励 |正序浏览 |阅读模式

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

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

x
根据论坛MV讨论区中原帖https://rpg.blue/thread-486903-1-1.html
2楼老大heise0711给出的解决办法,已经能在游戏中将菜单的“结束游戏-回到标题”改为直接结束游戏了。
方法如下“打开项目文件夹下的JS,打开rpg_windows.js文件,找到下面这段代码
Window_GameEnd.prototype.makeCommandList = function() {
    this.addCommand(TextManager.toTitle, 'toTitle');
    this.addCommand(TextManager.cancel,  'cancel');
};
然后再这段代码下面添加一段下面的代码,保存.
Scene_GameEnd.prototype.commandToTitle = function() {
SceneManager.exit();
};
再到数据库---把用语中把“回到标题”修改成“结束游戏”

重新打开游戏你就会发现你点击回到标题就变成了“退出游戏”了”

但还请问大家,如何在不删除菜单“结束游戏-回到标题”的情况下,重新加入一个“结束游戏”按钮呢?
还有标题界面中我用“https://github.com/arrosev/RPGMakerMZPlugins”加入结束游戏好像不太管用。

Lv3.寻梦者

梦石
0
星屑
2291
在线时间
206 小时
注册时间
2023-11-16
帖子
112
7
发表于 2024-8-6 00:30:39 | 只看该作者
上面说得对,你首先得在按钮列表注册加入一个新的按钮然后才能绑定按键和功能。还有就是不建议修改核心文件,最好写个插件
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1491
在线时间
426 小时
注册时间
2023-5-18
帖子
155
6
发表于 2024-8-5 15:26:57 | 只看该作者
本帖最后由 Arrose 于 2024-8-5 15:30 编辑
18610358578 发表于 2024-8-5 14:46
是啊,加了按钮但没出现,我在rmmz_scenes.js里加入了但没出现第四个按钮,是我要改成Scene_Title.prototyp ...


还有标题界面中我用“https://github.com/arrosev/RPGMakerMZPlugins”加入结束游戏好像不太管用。”,我还以为你是拿插件加的“结束游戏”按钮,插件你怎么用的,有先看教学视频吗?

不用插件的话,代码里加就是:
  1. Window_TitleCommand.prototype.makeCommandList = function() {
  2.     const continueEnabled = this.isContinueEnabled();
  3.     this.addCommand(TextManager.newGame, "newGame");
  4.     this.addCommand(TextManager.continue_, "continue", continueEnabled);
  5.     this.addCommand(TextManager.options, "options");
  6.     this.addCommand("Game End", "gameend");
  7. };
复制代码
B站传送门
-----------------------------------------------------------------------
“与其为做不到的事耿耿于怀,不如为自己做到的事而喜悦
吧!”

-----------------------------------------------------------------------
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
17
在线时间
3 小时
注册时间
2024-7-31
帖子
5
5
 楼主| 发表于 2024-8-5 14:46:28 | 只看该作者
本帖最后由 18610358578 于 2024-8-5 14:56 编辑

是啊,加了按钮但没出现,我在rmmz_scenes.js里加入了
  1. Scene_Title.prototype.createCommandWindow = function() {
  2.     const background = $dataSystem.titleCommandWindow.background;
  3.     const rect = this.commandWindowRect();
  4.     this._commandWindow = new Window_TitleCommand(rect);
  5.     this._commandWindow.setBackgroundType(background);
  6.     this._commandWindow.setHandler("newGame", this.commandNewGame.bind(this));
  7.     this._commandWindow.setHandler("continue", this.commandContinue.bind(this));
  8.     this._commandWindow.setHandler("options", this.commandOptions.bind(this));
  9.         this._commandWindow.setHandler("gameend", this.commandgameend.bind(this));
  10.     this.addWindow(this._commandWindow);
  11. };

  12. Scene_Title.prototype.commandWindowRect = function() {
  13.     const offsetX = $dataSystem.titleCommandWindow.offsetX;
  14.     const offsetY = $dataSystem.titleCommandWindow.offsetY;
  15.     const ww = this.mainCommandWidth();
  16.     const wh = this.calcWindowHeight(4, true);
  17.     const wx = (Graphics.boxWidth - ww) / 2 + offsetX;
  18.     const wy = Graphics.boxHeight - wh - 96 + offsetY;
  19.     return new Rectangle(wx, wy, ww, wh);
  20. };

  21. Scene_Title.prototype.commandNewGame = function() {
  22.     DataManager.setupNewGame();
  23.     this._commandWindow.close();
  24.     this.fadeOutAll();
  25.     SceneManager.goto(Scene_Map);
  26. };

  27. Scene_Title.prototype.commandContinue = function() {
  28.     this._commandWindow.close();
  29.     SceneManager.push(Scene_Load);
  30. };

  31. Scene_Title.prototype.commandOptions = function() {
  32.     this._commandWindow.close();
  33.     SceneManager.push(Scene_Options);
  34. };

  35. Scene_Title.prototype.commandgameend = function() {
  36. SceneManager.exit();
  37. };
复制代码
但没出现第四个按钮,是我要改成Scene_Title.prototype.commandgameend = function() {
    this._commandWindow.close();
    SceneManager.push(Scene_exit)再添加一个Scene_exit?
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1491
在线时间
426 小时
注册时间
2023-5-18
帖子
155
4
发表于 2024-8-5 09:14:12 | 只看该作者
你在“结束游戏”按钮的脚本里写SceneManager.exit(); 试试,还是说你加了按钮但是按钮没出现
B站传送门
-----------------------------------------------------------------------
“与其为做不到的事耿耿于怀,不如为自己做到的事而喜悦
吧!”

-----------------------------------------------------------------------
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
17
在线时间
3 小时
注册时间
2024-7-31
帖子
5
3
 楼主| 发表于 2024-8-5 08:47:01 | 只看该作者
论坛中有个添加全屏和退出游戏的js,我忘记地址了是大佬翻译的54个中文合集里的,其中代码是
function Scene_Terminate() {
    this.initialize.apply(this, arguments);
}


(function () {
    'use strict'; // 启用严格模式

    // 如果不是在Nw.js环境下,则不执行以下任何功能
    if (!Utils.isNwjs()) {
        return;
    }

    var pluginName = 'StartUpFullScreen'; // 插件名称

    // 获取参数值的辅助函数,如果找到则返回,否则返回空字符串
    var getParamString = function(paramNames) {
        var value = getParamOther(paramNames);
        return value == null ? '' : value;
    };

    // 通用函数,用于从插件参数中获取指定名称的值
    var getParamOther = function(paramNames) {
        if (!Array.isArray(paramNames)) paramNames = [paramNames]; // 确保传入的是数组
        for (var i = 0; i < paramNames.length; i++) {
            var name = PluginManager.parameters(pluginName)[paramNames[i]]; // 从插件参数中获取值
            if (name) return name; // 如果找到值,则返回
        }
        return null; // 如果没有找到任何值,则返回null
    };

    // 获取插件参数的特定值,用于控制关闭和全屏启动的行为
    var paramShutdown = getParamString(['Shutdown', '退出游戏']);
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
17
在线时间
3 小时
注册时间
2024-7-31
帖子
5
2
 楼主| 发表于 2024-8-5 08:37:09 | 只看该作者
我在论坛中已经找到能够退出游戏的插件了,但是还是想问下上述问题,因为想仿照学习下。
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-21 00:48

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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