码迷,mamicode.com
首页 > Web开发 > 详细

rpgmakermv插件(1)screenfull.js与Fullscreen.js

时间:2018-02-23 20:57:56      阅读:325      评论:0      收藏:0      [点我收藏+]

标签:--   read   世界   etc   col   des   两种   function   32位   

本文分析游戏的全屏化处理。

 

引入:玩家在不同情景下可能会选择全屏游戏或窗口化游戏,所以作为开发者,应该在设置中加入全屏与否的选项。

 

两种插件:screenfull.js与Fullscreen.js

 

 

 

1.screenfull

// MV 1.5.0 for Win7 - 32位


var _CmdName = ‘窗口模式‘;// 指令名称
var _CmdSymbol = ‘fullScreen‘;// 指令标识
ConfigManager[_CmdSymbol] = false;//初始化指令状态


/*--- 启动自检 ---*/
var _SBS = Scene_Boot.prototype.start;
Scene_Boot.prototype.start = function() {
var value = ConfigManager[_CmdSymbol];
Graphics._changeScreen(value);
_SBS.call(this);
};


/*--- 选项处理 ---*/
Window_Options.prototype.makeCommandList = function() {
this.addGeneralOptions();
this.addCommand(_CmdName, _CmdSymbol);//<<<
this.addVolumeOptions();
};


/*--- 触发处理 ---*/
var _WOPOK = Window_Options.prototype.processOk;
Window_Options.prototype.processOk = function() {
_WOPOK.call(this);
var index = this.index();
var symbol = this.commandSymbol(index);
var value = this.getConfigValue(symbol);
if(symbol == _CmdSymbol){
Graphics._changeScreen(value);
}
};


/*--- 切屏处理---*/
Graphics._changeScreen = function(state) {
if (state) {
this._requestFullScreen();
} else {
this._cancelFullScreen();
}
};


/*--- 记录处理 ---*/
var _CMMD = ConfigManager.makeData;
ConfigManager.makeData = function() {
var config = _CMMD.call(this);
config[_CmdSymbol] = ConfigManager[_CmdSymbol];
return config;
};


var _CMAD = ConfigManager.applyData;
ConfigManager.applyData = function(config) {
_CMAD.call(this, config);
ConfigManager[_CmdSymbol] = this.readFlag(config, _CmdSymbol);
};

 

优:简单快捷,

缺点:进入游戏会发现游戏世界的宽高还是窗口化时的,两边会出现黑边。

 

2.Fullscreen

//=============================================================================
// Fullscreen.js
//=============================================================================
 
/*:
 * @plugindesc Starts the game in fullscreen
 * @author Christian Schicho
 *
 * @help
 */
 
;(function() {
  function extend(obj, name, func) {
    var orig = obj.prototype[name]
    obj.prototype[name] = function() {
      orig.call(this)
      func.call(this)
    }
  }
 
  extend(Scene_Boot, ‘start‘, function() {
        Graphics._switchFullScreen();
  })
  
  
 var _Scene_Base_create = Scene_Base.prototype.create;

    Scene_Base.prototype.create = function() {
        _Scene_Base_create.call(this);
        Graphics.width = 1280;
        Graphics.height = 720;    
        Graphics.boxHeight = 720;
        Graphics.boxWidth = 1280;    
    };
 
})()

 

优:无论全屏还是窗口化,界面显示都是正常。

缺点:用户不可控

 

 

将两者结合起来,就是比较完美的解决方案了。

关于结合版,将在下文揭晓。

rpgmakermv插件(1)screenfull.js与Fullscreen.js

标签:--   read   世界   etc   col   des   两种   function   32位   

原文地址:https://www.cnblogs.com/empist/p/8463125.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!