Scene_Title.prototype.createBackground = function() {this._backSprite1 = new Sprite(ImageManager.loadTitle1($dataSystem.title1Name));this._backSprite2 = new Sprite(ImageManager.loadTitle2($dataSystem.title2Name));this.addChild(this._backSprite1);this.addChild(this._backSprite2);};
Scene_Title.prototype.createBackground = function() {};
this._backSprite1 = new Sprite(ImageManager.loadTitle1($dataSystem.title1Name));
Scene_Title.prototype.createBackground = function() {this._backSprite1 = new Sprite(ImageManager.loadTitle1('Dragon'));// this._backSprite2 = new Sprite(ImageManager.loadTitle2($dataSystem.title2Name));this.addChild(this._backSprite1);// this.addChild(this._backSprite2);};
this._backSprite2 = new Sprite(ImageManager.loadTitle2('Floral'));
this.addChild(this._backSprite2);this.addChild(this._backSprite1);
function Scene_Title() {this.initialize.apply(this, arguments);}Scene_Title.prototype = Object.create(Scene_Base.prototype);Scene_Title.prototype.constructor = Scene_Title;Scene_Title.prototype.initialize = function() {Scene_Base.prototype.initialize.call(this);};
Scene_Title.prototype.create = function() {Scene_Base.prototype.create.call(this);//繼承Scene_Base.prototype.createthis.createBackground();// 這裡叫了讀背景的函式this.createForeground();this.createWindowLayer();this.createCommandWindow();// 這裡叫了命令視窗};
Scene_Title.prototype.start = function() {Scene_Base.prototype.start.call(this);//繼承Scene_Base.prototype.startSceneManager.clearStack();this.centerSprite(this._backSprite1);// 這裡叫了背景用的圖1this.centerSprite(this._backSprite2);// 這裡叫了背景用的圖2this.playTitleMusic();// 這裡叫了背景音樂this.startFadeIn(this.fadeSpeed(), false);// 這裡設(shè)定淡入顯示};
/*** Create the components and add them to the rendering process.** @method create* @instance* @memberof Scene_Base*/Scene_Base.prototype.create = function() {};
/*** Start the scene processing.** @method start* @instance* @memberof Scene_Base*/Scene_Base.prototype.start = function() {this._active = true;};
Scene_Title.prototype.update = function() {if (!this.isBusy()) {this._commandWindow.open();}Scene_Base.prototype.update.call(this);};
/*** Update the scene processing each new frame.** @method update* @instance* @memberof Scene_Base*/Scene_Base.prototype.update = function() {this.updateFade();this.updateChildren();};
這段的內(nèi)容是創(chuàng)建一個(gè)視窗,名字是this._commandWindowScene_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.initialize = function() {Window_Command.prototype.initialize.call(this, 0, 0);this.updatePlacement();this.openness = 0;this.selectLast();};
'newGame''continue''options'
this._commandWindow.setHandler( 'newGame' , this.commandNewGame.bind(this) );//this._commandWindow.setHandler( '命令名稱' , 命令後執(zhí)行的對象函式)Scene_Title.prototype.commandNewGame = function() {
DataManager.setupNewGame();this._commandWindow.close();this.fadeOutAll();SceneManager.goto(Scene_Map);};
以上兩段翻譯成白話就是,當(dāng)我點(diǎn)了'newGame' 後,會(huì)執(zhí)行Scene_Title.prototype.commandNewGame = function()這個(gè)函式的內(nèi)容。內(nèi)容其實(shí)也很簡單,就關(guān)閉標(biāo)題視窗後移動(dòng)到Scene_Map去。
Scene_Title.prototype.commandContinue = function() {this._commandWindow.close();SceneManager.push(Scene_Load);};Scene_Title.prototype.commandOptions = function() {this._commandWindow.close();SceneManager.push(Scene_Options);};
Scene_Title.prototype.createCommandWindow = function() {this._commandWindow = new Window_TitleCommand();this._commandWindow.x = 100;this._commandWindow.y = 120;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);};
再來改多一點(diǎn),像這樣:
結(jié)果呢:Scene_Title.prototype.createCommandWindow = function() {this._commandWindow = new Window_TitleCommand();this._commandWindow.x = 100;this._commandWindow.y = 120;this._commandWindow.width = 300;this._commandWindow.height = 400;this._commandWindow.windowskin = ImageManager.loadSystem('Window_03');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');};
Window_TitleCommand.prototype.makeCommandList = function() {this.addCommand(TextManager.newGame, 'newGame');this.addCommand(TextManager.continue_, 'continue', this.isContinueEnabled());this.addCommand(TextManager.options, 'options');this.addCommand( '選項(xiàng)3', 'command3');this.addCommand( '選項(xiàng)4', 'command4');this.addCommand( '選項(xiàng)5', 'command5');this.addCommand( '選項(xiàng)6', 'command6');};