查看: 4821|回复: 9

[交流讨论] MV运行高速化

[复制链接]
梦石
0
星屑
440
在线时间
679 小时
注册时间
2014-3-15
回帖
239

开拓者

发表于 2017-8-2 14:00:13 | 显示全部楼层 |阅读模式

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

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

×
MV加入了一堆功能虽然提升了利用度,但是效率仍然是低的令人发指。除去JS不讨论,其中最浪费运行效率的是不该创建的窗口创建,以及无用的对象在不停的update,于是在需要的时候update,删除不必要的窗口是可行的方案。
举个例子:当你使用Yanfly的ATB插件与Mog 的Bhud插件时,statusWindow就是完全不需要的窗口,而Yanfly的ATB仍然在不停的更新ATB条,但是你又看不见,因为mog直接将其透明度调到0.所以这是一个极为浪费的过程,并且默认启用ActorCommand,PartyCommand直接被无视掉了,方法就是删掉与statuswindow及PartyCommand相关的东西,举个例子:
  1. Scene_Battle.prototype.createDisplayObjects = function() {
  2.     this.createSpriteset();
  3.     this.createWindowLayer();
  4.     this.createAllWindows();
  5.     BattleManager.setLogWindow(this._logWindow);
  6.     BattleManager.setSpriteset(this._spriteset);
  7.     this._logWindow.setSpriteset(this._spriteset);
  8. };

  9. Scene_Battle.prototype.createAllWindows = function() {
  10.     this.createLogWindow();
  11.     this.createActorCommandWindow();
  12.     this.createHelpWindow();
  13.     this.createSkillWindow();
  14.     this.createItemWindow();
  15.     this.createActorWindow();
  16.     this.createEnemyWindow();
  17.     this.createMessageWindow();
  18. };

  19. Scene_Battle.prototype.isAnyInputWindowActive = function() {
  20.     return (this._actorCommandWindow.active || this._skillWindow.active || this._itemWindow.active || this._actorWindow.active || this._enemyWindow.active);
  21. };

  22. Scene_Battle.prototype.changeInputWindow = function() {
  23.     if (BattleManager.isInputting()) {
  24.         if (BattleManager.actor()) {
  25.             this.startActorCommandSelection();
  26.         }
  27.     } else {
  28.         this.endCommandSelection();
  29.     }
  30. };

  31. Scene_Battle.prototype.endCommandSelection = function() {
  32.     this._actorCommandWindow.close();
  33. };

  34. Scene_Battle.prototype.startActorCommandSelection = function() {
  35.     this._actorCommandWindow.setup(BattleManager.actor());
  36. };

  37. Scene_Battle.prototype.createSkillWindow = function() {
  38.     var wy = this._helpWindow.y + this._helpWindow.height;
  39.     var wh = 0;
  40.     this._skillWindow = new Window_BattleSkill(0, wy, Graphics.boxWidth, wh);
  41.     this._skillWindow.setHelpWindow(this._helpWindow);
  42.     this._skillWindow.setHandler('ok',     this.onSkillOk.bind(this));
  43.     this._skillWindow.setHandler('cancel', this.onSkillCancel.bind(this));
  44.     this.addWindow(this._skillWindow);
  45. };

  46. Scene_Battle.prototype.createItemWindow = function() {
  47.     var wy = this._helpWindow.y + this._helpWindow.height;
  48.     var wh = 0;
  49.     this._itemWindow = new Window_BattleItem(0, wy, Graphics.boxWidth, wh);
  50.     this._itemWindow.setHelpWindow(this._helpWindow);
  51.     this._itemWindow.setHandler('ok',     this.onItemOk.bind(this));
  52.     this._itemWindow.setHandler('cancel', this.onItemCancel.bind(this));
  53.     this.addWindow(this._itemWindow);
  54. };

  55. Scene_Battle.prototype.createActorWindow = function() {
  56.     this._actorWindow = new Window_BattleActor(0, 0);
  57.     this._actorWindow.setHandler('ok',     this.onActorOk.bind(this));
  58.     this._actorWindow.setHandler('cancel', this.onActorCancel.bind(this));
  59.     this.addWindow(this._actorWindow);
  60. };

  61. Scene_Battle.prototype.createEnemyWindow = function() {
  62.     this._enemyWindow = new Window_BattleEnemy(0, 0);
  63.     this._enemyWindow.x = Graphics.boxWidth - this._enemyWindow.width;
  64.     this._enemyWindow.setHandler('ok',     this.onEnemyOk.bind(this));
  65.     this._enemyWindow.setHandler('cancel', this.onEnemyCancel.bind(this));
  66.     this.addWindow(this._enemyWindow);
  67. };

  68. Scene_Battle.prototype.updateWindowPositions = function() {
  69. };

  70. Scene_Battle.prototype.updateStatusWindow = function() {
  71.     if ($gameMessage.isBusy()) {
  72.         this._actorCommandWindow.close();
  73.     }
  74. };

  75. BattleManager.setStatusWindow = function(statusWindow) {
  76. };

  77. BattleManager.refreshStatus = function() {
  78. };
复制代码


战斗中隐藏的窗口不需要刷新(前提是你不需要),等到显现出来时才需要,所以:
  1. Window_Base.prototype.update = function() {
  2.     if ($gameParty.inBattle() && !this.visible) return;
  3.     Window.prototype.update.call(this);
  4.     this.updateTone();
  5.     this.updateOpen();
  6.     this.updateClose();
  7.     this.updateBackgroundDimmer();
  8. };
复制代码


如果你不用鼠标功能的话,为什么要留着算力给touchinput更新呢?
  1. SceneManager.initInput = function() {
  2.     Input.initialize();
  3. };

  4. SceneManager.updateInputData = function() {
  5.     Input.update();
  6. };

  7. Game_Player.prototype.triggerTouchActionD1 = function(x1, y1) {
  8.     if ($gameMap.airship().pos(x1, y1)) {
  9.         if (this.getOnOffVehicle()) {
  10.             return true;
  11.         }
  12.     }
  13.     this.checkEventTriggerHere([0]);
  14.     return $gameMap.setupStartingEvent();
  15. };

  16. Game_Player.prototype.triggerTouchActionD2 = function(x2, y2) {
  17.     if ($gameMap.boat().pos(x2, y2) || $gameMap.ship().pos(x2, y2)) {
  18.         if (this.getOnVehicle()) {
  19.             return true;
  20.         }
  21.     }
  22.     if (this.isInBoat() || this.isInShip()) {
  23.         if (this.getOffVehicle()) {
  24.             return true;
  25.         }
  26.     }
  27.     this.checkEventTriggerThere([0,1,2]);
  28.     return $gameMap.setupStartingEvent();
  29. };

  30. Scene_Map.prototype.isFastForward = function() {
  31.     return ($gameMap.isEventRunning() && !SceneManager.isSceneChanging() &&
  32.             Input.isLongPressed('ok'));
  33. };

  34. Scene_Map.prototype.isMenuCalled = function() {
  35.     return Input.isTriggered('menu');
  36. };

  37. Scene_Gameover.prototype.isTriggered = function() {
  38.     return Input.isTriggered('ok');
  39. };

  40. Scene_Map.prototype.updateDestination = function() {
  41.     $gameTemp.clearDestination();
  42.     this._touchCount = 0;
  43. };

  44. Window_Selectable.prototype.update = function() {
  45.     Window_Base.prototype.update.call(this);
  46.     this.updateArrows();
  47.     this.processCursorMove();
  48.     this.processHandling();
  49.     this._stayCount++;
  50. };

  51. Window_ShopStatus.prototype.isPageChangeRequested = function() {
  52.     if (Input.isTriggered('shift')) {
  53.         return true;
  54.     }
  55.     return false;
  56. };

  57. Window_Message.prototype.isTriggered = function() {
  58.     return (Input.isRepeated('ok') || Input.isRepeated('cancel'));
  59. };

  60. Window_ScrollText.prototype.isFastForward = function() {
  61.     if ($gameMessage.scrollNoFast()) {
  62.         return false;
  63.     } else {
  64.         return (Input.isPressed('ok') || Input.isPressed('shift'));
  65.     }
  66. };

  67. Window_BattleLog.prototype.isFastForward = function() {
  68.     return (Input.isLongPressed('ok') || Input.isPressed('shift'));
  69. };

  70. Window_Selectable.prototype.updateInputData = function() {
  71.     Input.update();
  72. };
复制代码


既然鼠标不让用,留着商店里按的图标也没意思了:
  1. Window_NumberInput.prototype.initialize = function(messageWindow) {
  2.     this._messageWindow = messageWindow;
  3.     Window_Selectable.prototype.initialize.call(this, 0, 0, 0, 0);
  4.     this._number = 0;
  5.     this._maxDigits = 1;
  6.     this.openness = 0;
  7.     this.deactivate();
  8. };

  9. Window_ShopNumber.prototype.initialize = function(x, y, height) {
  10.     var width = this.windowWidth();
  11.     Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  12.     this._item = null;
  13.     this._max = 1;
  14.     this._price = 0;
  15.     this._number = 1;
  16.     this._currencyUnit = TextManager.currencyUnit;
  17. };

  18. Window_ShopNumber.prototype.setup = function(item, max, price) {
  19.     this._item = item;
  20.     this._max = Math.floor(max);
  21.     this._price = price;
  22.     this._number = 1;
  23.     this.refresh();
  24. };

  25. Window_NumberInput.prototype.start = function() {
  26.     this._maxDigits = $gameMessage.numInputMaxDigits();
  27.     this._number = $gameVariables.value($gameMessage.numInputVariableId());
  28.     this._number = this._number.clamp(0, Math.pow(10, this._maxDigits) - 1);
  29.     this.updatePlacement();
  30.     this.createContents();
  31.     this.refresh();
  32.     this.open();
  33.     this.activate();
  34.     this.select(0);
  35. };
复制代码


使用mog地图名字的话,mapwindow完全多余
  1. Scene_Map.prototype.createDisplayObjects = function() {
  2.     this.createSpriteset();
  3.     this.createWindowLayer();
  4.     this.createAllWindows();
  5. };

  6. Scene_Map.prototype.callMenu = function() {
  7.     SoundManager.playOk();
  8.     SceneManager.push(Scene_Menu);
  9.     Window_MenuCommand.initCommandPosition();
  10.     $gameTemp.clearDestination();
  11.     this._waitCount = 2;
  12. };

  13. Scene_Map.prototype.launchBattle = function() {
  14.     BattleManager.saveBgmAndBgs();
  15.     this.stopAudioOnBattleStart();
  16.     SoundManager.playBattleStart();
  17.     this.startEncounterEffect();
  18. };

  19. Scene_Map.prototype.start = function() {
  20.     Scene_Base.prototype.start.call(this);
  21.     SceneManager.clearStack();
  22.     if (this._transfer) {
  23.         this.fadeInForTransfer();
  24.         $gameMap.autoplay();
  25.     } else if (this.needsFadeIn()) {
  26.         this.startFadeIn(this.fadeSpeed(), false);
  27.     }
  28.     this.menuCalling = false;
  29. };

  30. Scene_Map.prototype.terminate = function() {
  31.     Scene_Base.prototype.terminate.call(this);
  32.     if (!SceneManager.isNextScene(Scene_Battle)) {
  33.         this._spriteset.update();
  34.         SceneManager.snapForBackground();
  35.     } else {
  36.         ImageManager.clearRequest();
  37.     }
  38.     if (SceneManager.isNextScene(Scene_Map)) {
  39.         ImageManager.clearRequest();
  40.     }
  41.     $gameScreen.clearZoom();
  42.     this.removeChild(this._fadeSprite);
  43.     this.removeChild(this._windowLayer);
  44.     this.removeChild(this._spriteset);
  45. };
复制代码


抛砖引玉,有什么想法在更新

评分

参与人数 2星屑 +150 收起 理由
doranikofu + 30 塞糖
garfeng + 120 塞糖

查看全部评分

老黄鸡

梦石
4
星屑
46133
在线时间
7978 小时
注册时间
2009-7-6
回帖
13342

MZ评测员RM创作大赛01组委会开拓者贵宾

发表于 2017-8-2 15:04:16 | 显示全部楼层
只能按需修改,默认系统包含太多用不上的东西,不可能一点点全部去掉呀。

点评

所以这个东西还得靠自己一点一点弄,不过一般来说鼠标系统确实是用不上而且很浪费资源  发表于 2017-8-2 16:11
RGDirect - DirectX驱动的RGSS,点我了解.
(排满,暂停)RM全系列成套系统定制请联系QQ1213237796
不接受对其他插件维护的委托
回复

使用道具 举报

梦石
0
星屑
4060
在线时间
836 小时
注册时间
2013-7-29
回帖
145

开拓者

发表于 2017-8-2 15:30:24 | 显示全部楼层
RPG制作大师 面向的 更多的是一般玩家。

点评

不过流畅也是很重要的  发表于 2017-8-2 16:13
现在论坛上的少,有事联系
QQ:2287688663
回复

使用道具 举报

梦石
0
星屑
1246
在线时间
179 小时
注册时间
2016-6-1
回帖
30
发表于 2017-8-2 15:35:36 | 显示全部楼层
LZ很强大,可以+一下Q回头帮忙定制一下优化嘛

点评

别啊,价格好商量,我就喜欢黑科技大佬  发表于 2017-8-3 09:19
呃还是算了,主要时间腾不出来,不过一般的忙还是可以的  发表于 2017-8-2 16:09
回复

使用道具 举报

梦石
0
星屑
676
在线时间
224 小时
注册时间
2006-12-7
回帖
780
发表于 2017-8-4 14:35:50 | 显示全部楼层
window base那个感觉不错 回头试试去

这有人也做过一个优化,具体不太懂,也不知道效果有多好
https://github.com/lekoder/rpgmaker-optimization
回复

使用道具 举报

梦石
0
星屑
440
在线时间
679 小时
注册时间
2014-3-15
回帖
239

开拓者

 楼主| 发表于 2017-8-4 16:26:14 | 显示全部楼层
doranikofu 发表于 2017-8-4 14:35
window base那个感觉不错 回头试试去

这有人也做过一个优化,具体不太懂,也不知道效果有多好

似乎是增强了FPS,但是消耗的资源就更多了。
目前来说我的目标就是让窗口在不该Update的地方不要update,然后删除一些极少用到的功能。
战斗场景这么改减少了很多消耗
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部