比较基础的类(继承后比较好处理)
Scene已经试过继承的类关系图
Stage
↓
Scene_Base
∟Scene_MenuBase
∟Scene_ItemBaseWindow已经试过继承的类关系图
Window
↓
Window_Base
∟Window_Selectable
∟Window_Command
∟Window_NameInput//这个类与下面那个类配合就是起名
∟Window_NameEdit 字的界面
上面是一些比较基础的类,尝试继承写自己的界面
下面是一个创建三个选项的脚本
按F8在里面输入SceneManager.push(Scene_Custom)就可以得到左边的三个选项
custom.js
function Scene_Custom(){
this.initialize.apply(this,arguments);
};
Scene_Custom.prototype=Object.create(Scene_MenuBase.prototype);
Scene_Custom.prototype.constructor=Scene_Custom;
Scene_Custom.prototype.initialize=function(){
Scene_MenuBase.prototype.initialize.call(this);
};
Scene_Custom.prototype.create=function(){
Scene_MenuBase.prototype.create.call(this);
this._CommandWnd=new Window_CustomCommand(100,100);
this._CommandWnd.setHandler("command1",this.OnCommand1.bind(this));
this._CommandWnd.setHandler("command2",this.OnCommand2.bind(this));
this._CommandWnd.setHandler("command3",this.OnCommand3.bind(this));
this.addWindow(this._CommandWnd);
};
Scene_Custom.prototype.OnCommand1=function(){
};
Scene_Custom.prototype.OnCommand2=function(){
};
Scene_Custom.prototype.OnCommand3=function(){
};
//------------------命令窗口定义------------------------------
function Window_CustomCommand(){
this.initialize.apply(this,arguments);
};
Window_CustomCommand.prototype=Object.create(Window_Command.prototype);
Window_CustomCommand.prototype.constructor=Window_CustomCommand;
Window_CustomCommand.prototype.initialize=function(x, y){
Window_Command.prototype.initialize.call(this,x,y);
};
Window_CustomCommand.prototype.makeCommandList=function(){
this.addCommand("1","command1",enabled);
this.addCommand("2","command2",enabled);
this.addCommand("3","command3",enabled);
};
Window_CustomCommand.prototype.windowWidth = function() {
return 240;
};
开始菜单选项拓展
开始界面的场景名叫Scene_Title依附它的窗口是Window_TitleCommand
其中主要拓展函数是,如下
Scene_Title.prototype.createCommandWindow = function() {
this._commandWindow = new Window_TitleCommand();
this._commandWindow.setHandler('newGame', this.commandNewGame.bind(this));
this._commandWindow.setHandler('continue', this.commandContinue.bind(this));
this._commandWindow.setHandler('options', this.commandOptions.bind(this));
this.addWindow(this._commandWindow);
};
Window_TitleCommand.prototype.makeCommandList = function() {
this.addCommand(TextManager.newGame, 'newGame');
this.addCommand(TextManager.continue_, 'continue', this.isContinueEnabled());
this.addCommand(TextManager.options, 'options');
};
下面加一个CG选项
另起一个脚本
extend.js
_scene_title_extend=Scene_Title.prototype.createCommandWindow;
Scene_Title.prototype.createCommandWindow = function() {
_scene_title_extend.call(this);
this._commandWindow.setHandler("cgpicture",this.OnCg.bind(this));
};
Scene_Title.prototype.OnCg=function(){
//对CG按钮想加的功能,比如退出
SceneManager.pop();
};
_window_titlecommand_extend=Window_TitleCommand.prototype.makeCommandList
Window_TitleCommand.prototype.makeCommandList = function() {
_window_titlecommand_extend.call(this);
this.addCommand("CG","cgpicture");//第一个是键显示的名字,第二个是值
//addCommand原型
//Window_Command.prototype.addCommand =function(name, symbol, enabled, ext) {
// if (enabled === undefined) {
// enabled = true;
// }
// if (ext === undefined) {
// ext = null;
// }
// this._list.push({ name: name, symbol: symbol, enabled: enabled, ext: ext});//here
//};
};