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

Project1

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

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

[复制链接]

Lv2.观梦者

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

开拓者

跳转到指定楼层
1
发表于 2017-8-2 14:00:13 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
MV加入了一堆功能虽然提升了利用度,但是效率仍然是低的令人发指。除去JS不讨论,其中最浪费运行效率的是不该创建的窗口创建,以及无用的对象在不停的update,于是在需要的时候update,删除不必要的窗口是可行的方案。
举个例子:当你使用Yanfly的ATB插件与Mog 的Bhud插件时,statusWindow就是完全不需要的窗口,而Yanfly的ATB仍然在不停的更新ATB条,但是你又看不见,因为mog直接将其透明度调到0.所以这是一个极为浪费的过程,并且默认启用ActorCommand,PartyCommand直接被无视掉了,方法就是删掉与statuswindow及PartyCommand相关的东西,举个例子:
JAVASCRIPT 代码复制
  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.  
  10. Scene_Battle.prototype.createAllWindows = function() {
  11.     this.createLogWindow();
  12.     this.createActorCommandWindow();
  13.     this.createHelpWindow();
  14.     this.createSkillWindow();
  15.     this.createItemWindow();
  16.     this.createActorWindow();
  17.     this.createEnemyWindow();
  18.     this.createMessageWindow();
  19. };
  20.  
  21. Scene_Battle.prototype.isAnyInputWindowActive = function() {
  22.     return (this._actorCommandWindow.active || this._skillWindow.active || this._itemWindow.active || this._actorWindow.active || this._enemyWindow.active);
  23. };
  24.  
  25. Scene_Battle.prototype.changeInputWindow = function() {
  26.     if (BattleManager.isInputting()) {
  27.         if (BattleManager.actor()) {
  28.             this.startActorCommandSelection();
  29.         }
  30.     } else {
  31.         this.endCommandSelection();
  32.     }
  33. };
  34.  
  35. Scene_Battle.prototype.endCommandSelection = function() {
  36.     this._actorCommandWindow.close();
  37. };
  38.  
  39. Scene_Battle.prototype.startActorCommandSelection = function() {
  40.     this._actorCommandWindow.setup(BattleManager.actor());
  41. };
  42.  
  43. Scene_Battle.prototype.createSkillWindow = function() {
  44.     var wy = this._helpWindow.y + this._helpWindow.height;
  45.     var wh = 0;
  46.     this._skillWindow = new Window_BattleSkill(0, wy, Graphics.boxWidth, wh);
  47.     this._skillWindow.setHelpWindow(this._helpWindow);
  48.     this._skillWindow.setHandler('ok',     this.onSkillOk.bind(this));
  49.     this._skillWindow.setHandler('cancel', this.onSkillCancel.bind(this));
  50.     this.addWindow(this._skillWindow);
  51. };
  52.  
  53. Scene_Battle.prototype.createItemWindow = function() {
  54.     var wy = this._helpWindow.y + this._helpWindow.height;
  55.     var wh = 0;
  56.     this._itemWindow = new Window_BattleItem(0, wy, Graphics.boxWidth, wh);
  57.     this._itemWindow.setHelpWindow(this._helpWindow);
  58.     this._itemWindow.setHandler('ok',     this.onItemOk.bind(this));
  59.     this._itemWindow.setHandler('cancel', this.onItemCancel.bind(this));
  60.     this.addWindow(this._itemWindow);
  61. };
  62.  
  63. Scene_Battle.prototype.createActorWindow = function() {
  64.     this._actorWindow = new Window_BattleActor(0, 0);
  65.     this._actorWindow.setHandler('ok',     this.onActorOk.bind(this));
  66.     this._actorWindow.setHandler('cancel', this.onActorCancel.bind(this));
  67.     this.addWindow(this._actorWindow);
  68. };
  69.  
  70. Scene_Battle.prototype.createEnemyWindow = function() {
  71.     this._enemyWindow = new Window_BattleEnemy(0, 0);
  72.     this._enemyWindow.x = Graphics.boxWidth - this._enemyWindow.width;
  73.     this._enemyWindow.setHandler('ok',     this.onEnemyOk.bind(this));
  74.     this._enemyWindow.setHandler('cancel', this.onEnemyCancel.bind(this));
  75.     this.addWindow(this._enemyWindow);
  76. };
  77.  
  78. Scene_Battle.prototype.updateWindowPositions = function() {
  79. };
  80.  
  81. Scene_Battle.prototype.updateStatusWindow = function() {
  82.     if ($gameMessage.isBusy()) {
  83.         this._actorCommandWindow.close();
  84.     }
  85. };
  86.  
  87. BattleManager.setStatusWindow = function(statusWindow) {
  88. };
  89.  
  90. BattleManager.refreshStatus = function() {
  91. };


战斗中隐藏的窗口不需要刷新(前提是你不需要),等到显现出来时才需要,所以:
JAVASCRIPT 代码复制
  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更新呢?
JAVASCRIPT 代码复制
  1. SceneManager.initInput = function() {
  2.     Input.initialize();
  3. };
  4.  
  5. SceneManager.updateInputData = function() {
  6.     Input.update();
  7. };
  8.  
  9. Game_Player.prototype.triggerTouchActionD1 = function(x1, y1) {
  10.     if ($gameMap.airship().pos(x1, y1)) {
  11.         if (this.getOnOffVehicle()) {
  12.             return true;
  13.         }
  14.     }
  15.     this.checkEventTriggerHere([0]);
  16.     return $gameMap.setupStartingEvent();
  17. };
  18.  
  19. Game_Player.prototype.triggerTouchActionD2 = function(x2, y2) {
  20.     if ($gameMap.boat().pos(x2, y2) || $gameMap.ship().pos(x2, y2)) {
  21.         if (this.getOnVehicle()) {
  22.             return true;
  23.         }
  24.     }
  25.     if (this.isInBoat() || this.isInShip()) {
  26.         if (this.getOffVehicle()) {
  27.             return true;
  28.         }
  29.     }
  30.     this.checkEventTriggerThere([0,1,2]);
  31.     return $gameMap.setupStartingEvent();
  32. };
  33.  
  34. Scene_Map.prototype.isFastForward = function() {
  35.     return ($gameMap.isEventRunning() && !SceneManager.isSceneChanging() &&
  36.             Input.isLongPressed('ok'));
  37. };
  38.  
  39. Scene_Map.prototype.isMenuCalled = function() {
  40.     return Input.isTriggered('menu');
  41. };
  42.  
  43. Scene_Gameover.prototype.isTriggered = function() {
  44.     return Input.isTriggered('ok');
  45. };
  46.  
  47. Scene_Map.prototype.updateDestination = function() {
  48.     $gameTemp.clearDestination();
  49.     this._touchCount = 0;
  50. };
  51.  
  52. Window_Selectable.prototype.update = function() {
  53.     Window_Base.prototype.update.call(this);
  54.     this.updateArrows();
  55.     this.processCursorMove();
  56.     this.processHandling();
  57.     this._stayCount++;
  58. };
  59.  
  60. Window_ShopStatus.prototype.isPageChangeRequested = function() {
  61.     if (Input.isTriggered('shift')) {
  62.         return true;
  63.     }
  64.     return false;
  65. };
  66.  
  67. Window_Message.prototype.isTriggered = function() {
  68.     return (Input.isRepeated('ok') || Input.isRepeated('cancel'));
  69. };
  70.  
  71. Window_ScrollText.prototype.isFastForward = function() {
  72.     if ($gameMessage.scrollNoFast()) {
  73.         return false;
  74.     } else {
  75.         return (Input.isPressed('ok') || Input.isPressed('shift'));
  76.     }
  77. };
  78.  
  79. Window_BattleLog.prototype.isFastForward = function() {
  80.     return (Input.isLongPressed('ok') || Input.isPressed('shift'));
  81. };
  82.  
  83. Window_Selectable.prototype.updateInputData = function() {
  84.     Input.update();
  85. };


既然鼠标不让用,留着商店里按的图标也没意思了:
JAVASCRIPT 代码复制
  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.  
  10. Window_ShopNumber.prototype.initialize = function(x, y, height) {
  11.     var width = this.windowWidth();
  12.     Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  13.     this._item = null;
  14.     this._max = 1;
  15.     this._price = 0;
  16.     this._number = 1;
  17.     this._currencyUnit = TextManager.currencyUnit;
  18. };
  19.  
  20. Window_ShopNumber.prototype.setup = function(item, max, price) {
  21.     this._item = item;
  22.     this._max = Math.floor(max);
  23.     this._price = price;
  24.     this._number = 1;
  25.     this.refresh();
  26. };
  27.  
  28. Window_NumberInput.prototype.start = function() {
  29.     this._maxDigits = $gameMessage.numInputMaxDigits();
  30.     this._number = $gameVariables.value($gameMessage.numInputVariableId());
  31.     this._number = this._number.clamp(0, Math.pow(10, this._maxDigits) - 1);
  32.     this.updatePlacement();
  33.     this.createContents();
  34.     this.refresh();
  35.     this.open();
  36.     this.activate();
  37.     this.select(0);
  38. };


使用mog地图名字的话,mapwindow完全多余
JAVASCRIPT 代码复制
  1. Scene_Map.prototype.createDisplayObjects = function() {
  2.     this.createSpriteset();
  3.     this.createWindowLayer();
  4.     this.createAllWindows();
  5. };
  6.  
  7. Scene_Map.prototype.callMenu = function() {
  8.     SoundManager.playOk();
  9.     SceneManager.push(Scene_Menu);
  10.     Window_MenuCommand.initCommandPosition();
  11.     $gameTemp.clearDestination();
  12.     this._waitCount = 2;
  13. };
  14.  
  15. Scene_Map.prototype.launchBattle = function() {
  16.     BattleManager.saveBgmAndBgs();
  17.     this.stopAudioOnBattleStart();
  18.     SoundManager.playBattleStart();
  19.     this.startEncounterEffect();
  20. };
  21.  
  22. Scene_Map.prototype.start = function() {
  23.     Scene_Base.prototype.start.call(this);
  24.     SceneManager.clearStack();
  25.     if (this._transfer) {
  26.         this.fadeInForTransfer();
  27.         $gameMap.autoplay();
  28.     } else if (this.needsFadeIn()) {
  29.         this.startFadeIn(this.fadeSpeed(), false);
  30.     }
  31.     this.menuCalling = false;
  32. };
  33.  
  34. Scene_Map.prototype.terminate = function() {
  35.     Scene_Base.prototype.terminate.call(this);
  36.     if (!SceneManager.isNextScene(Scene_Battle)) {
  37.         this._spriteset.update();
  38.         SceneManager.snapForBackground();
  39.     } else {
  40.         ImageManager.clearRequest();
  41.     }
  42.     if (SceneManager.isNextScene(Scene_Map)) {
  43.         ImageManager.clearRequest();
  44.     }
  45.     $gameScreen.clearZoom();
  46.     this.removeChild(this._fadeSprite);
  47.     this.removeChild(this._windowLayer);
  48.     this.removeChild(this._spriteset);
  49. };


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

评分

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

查看全部评分

Lv5.捕梦者 (管理员)

老黄鸡

梦石
0
星屑
40111
在线时间
7503 小时
注册时间
2009-7-6
帖子
13489

开拓者贵宾

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

点评

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

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3680
在线时间
826 小时
注册时间
2013-7-29
帖子
161

开拓者

3
发表于 2017-8-2 15:30:24 | 只看该作者
RPG制作大师 面向的 更多的是一般玩家。

点评

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

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1247
在线时间
179 小时
注册时间
2016-6-1
帖子
35
4
发表于 2017-8-2 15:35:36 | 只看该作者
LZ很强大,可以+一下Q回头帮忙定制一下优化嘛

点评

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

使用道具 举报

Lv2.观梦者

梦石
0
星屑
676
在线时间
224 小时
注册时间
2006-12-7
帖子
839
5
发表于 2017-8-4 14:35:50 | 只看该作者
window base那个感觉不错 回头试试去

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

使用道具 举报

Lv2.观梦者

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

开拓者

6
 楼主| 发表于 2017-8-4 16:26:14 | 只看该作者
doranikofu 发表于 2017-8-4 14:35
window base那个感觉不错 回头试试去

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

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

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-31 07:47

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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