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

Project1

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

[有事请教] 想请教一下原版的代码,有关调用菜单指令的方法

[复制链接]

Lv2.观梦者

梦石
0
星屑
362
在线时间
36 小时
注册时间
2018-12-29
帖子
35
1
发表于 2019-3-18 21:40:14 | 显示全部楼层
游鱼戏虾 发表于 2019-3-18 18:04
大佬我想问一下,我写了一个显示角色个人背景剧情的窗口,想要作为插件调用,于是把这个actorjs窗口绑定 ...

我也正在做新建窗口的测试,正好也遇到了一些小问题,看看能不能解决你的:

以我的小窗口作为例子,我是新增了一个系统选单,在Scene_Menu下新增了个_systemWindow

首先你需要有新建窗口的过程:

JAVASCRIPT 代码复制
  1. Scene_Menu.prototype.create = function () {
  2.     Scene_MenuBase.prototype.create.call(this);
  3.     this.createGoldWindow();
  4.     this.createCommandWindow();
  5.  
  6.     this.createSystemWindow();
  7.  
  8.     this.createStatusWindow();
  9. };


中间那个createSystemWindow()就是新建窗口的命令。这个函数仿照其他几个createWindow窗口的写法来写:

JAVASCRIPT 代码复制
  1. Scene_Menu.prototype.createSystemWindow = function () {
  2.     this._systemWindow = new Window_SystemMenuCommand(坐标, 坐标);
  3.  
  4.     this._systemWindow.setHandler('save', this.commandSave.bind(this));
  5.     this._systemWindow.setHandler('load', this.commandLoad.bind(this));
  6.     this._systemWindow.setHandler('options', this.commandOptions.bind(this));
  7.     this._systemWindow.setHandler('gameEnd', this.commandGameEnd.bind(this));
  8.     this._systemWindow.setHandler('cancel', this.onSystemCancel.bind(this));
  9.  
  10.     this.addWindow(this._systemWindow);
  11. };



第一行估计就是你不成功的关键,你需要把你的窗口new 一下,这样才能成立。最后addWindow一下,把你的窗口加进当前Scene下。然后各个句柄的函数都要写一下,所有没声明的都要声明。


然后,那个new的Window_SystemMenuCommand的整个类是要自己重写的……

这里实在是太多了就贴几个关键的:


JAVASCRIPT 代码复制
  1. function Window_SystemMenuCommand() {
  2.     this.initialize.apply(this, arguments);
  3. }
  4.  
  5. Window_SystemMenuCommand.prototype = Object.create(Window_Command.prototype);
  6. Window_SystemMenuCommand.prototype.constructor = Window_SystemMenuCommand;
  7.  
  8. Window_SystemMenuCommand.prototype.initialize = function (x, y) {
  9.     Window_Command.prototype.initialize.call(this, x, y);
  10.     this.select(last);
  11.  
  12. ………………后面很多很多很多很多
  13. };


简单来说你这个window可以照着你想模仿的那个窗口的完全代码都搬过来,虽然是完全复制但也得有这么一步,记得把名字改了,然后你需要的几个handler记得重写。

到这里大概明白了吗?你的Scene_actojs估计也是少了这个重写的过程,所以人家不认……

--------------------

当然我本身也是正在学写代码的萌新,这个不一定就是你遇到的那几个错误的问题,不过我这边写完的感觉就是无论是窗口Window,场景Scene,都要自己把类重写一下,要不然会各种问题的。

若有前辈指导发现我这边也有问题(笑)的话,你还是听人家的=w=

/  w\ 大家好我是飞剑Flysword,正在学习写js代码,希望能早日做出来自己的小游戏嘿嘿
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-18 14:13

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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