查看: 4774|回复: 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相关的东西,举个例子:[pre lang="javascript"]Scene_Battle.prototype.createDisplayObjects = function() {
    this.createSpriteset();
    this.createWindowLayer();
    this.createAllWindows();
    BattleManager.setLogWindow(this._logWindow);
    BattleManager.setSpriteset(this._spriteset);
    this._logWindow.setSpriteset(this._spriteset);
};

Scene_Battle.prototype.createAllWindows = function() {
    this.createLogWindow();
    this.createActorCommandWindow();
    this.createHelpWindow();
    this.createSkillWindow();
    this.createItemWindow();
    this.createActorWindow();
    this.createEnemyWindow();
    this.createMessageWindow();
};

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

Scene_Battle.prototype.changeInputWindow = function() {
    if (BattleManager.isInputting()) {
        if (BattleManager.actor()) {
            this.startActorCommandSelection();
        }
    } else {
        this.endCommandSelection();
    }
};

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

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

Scene_Battle.prototype.createSkillWindow = function() {
    var wy = this._helpWindow.y + this._helpWindow.height;
    var wh = 0;
    this._skillWindow = new Window_BattleSkill(0, wy, Graphics.boxWidth, wh);
    this._skillWindow.setHelpWindow(this._helpWindow);
    this._skillWindow.setHandler('ok',     this.onSkillOk.bind(this));
    this._skillWindow.setHandler('cancel', this.onSkillCancel.bind(this));
    this.addWindow(this._skillWindow);
};

Scene_Battle.prototype.createItemWindow = function() {
    var wy = this._helpWindow.y + this._helpWindow.height;
    var wh = 0;
    this._itemWindow = new Window_BattleItem(0, wy, Graphics.boxWidth, wh);
    this._itemWindow.setHelpWindow(this._helpWindow);
    this._itemWindow.setHandler('ok',     this.onItemOk.bind(this));
    this._itemWindow.setHandler('cancel', this.onItemCancel.bind(this));
    this.addWindow(this._itemWindow);
};

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

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

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

Scene_Battle.prototype.updateStatusWindow = function() {
    if ($gameMessage.isBusy()) {
        this._actorCommandWindow.close();
    }
};

BattleManager.setStatusWindow = function(statusWindow) {
};

BattleManager.refreshStatus = function() {
};
[/pre]

战斗中隐藏的窗口不需要刷新(前提是你不需要),等到显现出来时才需要,所以:
[pre lang="javascript"]Window_Base.prototype.update = function() {
    if ($gameParty.inBattle() && !this.visible) return;
    Window.prototype.update.call(this);
    this.updateTone();
    this.updateOpen();
    this.updateClose();
    this.updateBackgroundDimmer();
};[/pre]

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

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

Game_Player.prototype.triggerTouchActionD1 = function(x1, y1) {
    if ($gameMap.airship().pos(x1, y1)) {
        if (this.getOnOffVehicle()) {
            return true;
        }
    }
    this.checkEventTriggerHere([0]);
    return $gameMap.setupStartingEvent();
};

Game_Player.prototype.triggerTouchActionD2 = function(x2, y2) {
    if ($gameMap.boat().pos(x2, y2) || $gameMap.ship().pos(x2, y2)) {
        if (this.getOnVehicle()) {
            return true;
        }
    }
    if (this.isInBoat() || this.isInShip()) {
        if (this.getOffVehicle()) {
            return true;
        }
    }
    this.checkEventTriggerThere([0,1,2]);
    return $gameMap.setupStartingEvent();
};

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

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

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

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

Window_Selectable.prototype.update = function() {
    Window_Base.prototype.update.call(this);
    this.updateArrows();
    this.processCursorMove();
    this.processHandling();
    this._stayCount++;
};

Window_ShopStatus.prototype.isPageChangeRequested = function() {
    if (Input.isTriggered('shift')) {
        return true;
    }
    return false;
};

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

Window_ScrollText.prototype.isFastForward = function() {
    if ($gameMessage.scrollNoFast()) {
        return false;
    } else {
        return (Input.isPressed('ok') || Input.isPressed('shift'));
    }
};

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

Window_Selectable.prototype.updateInputData = function() {
    Input.update();
};
[/pre]

既然鼠标不让用,留着商店里按的图标也没意思了:
[pre lang="javascript"]Window_NumberInput.prototype.initialize = function(messageWindow) {
    this._messageWindow = messageWindow;
    Window_Selectable.prototype.initialize.call(this, 0, 0, 0, 0);
    this._number = 0;
    this._maxDigits = 1;
    this.openness = 0;
    this.deactivate();
};

Window_ShopNumber.prototype.initialize = function(x, y, height) {
    var width = this.windowWidth();
    Window_Selectable.prototype.initialize.call(this, x, y, width, height);
    this._item = null;
    this._max = 1;
    this._price = 0;
    this._number = 1;
    this._currencyUnit = TextManager.currencyUnit;
};

Window_ShopNumber.prototype.setup = function(item, max, price) {
    this._item = item;
    this._max = Math.floor(max);
    this._price = price;
    this._number = 1;
    this.refresh();
};

Window_NumberInput.prototype.start = function() {
    this._maxDigits = $gameMessage.numInputMaxDigits();
    this._number = $gameVariables.value($gameMessage.numInputVariableId());
    this._number = this._number.clamp(0, Math.pow(10, this._maxDigits) - 1);
    this.updatePlacement();
    this.createContents();
    this.refresh();
    this.open();
    this.activate();
    this.select(0);
};
[/pre]

使用mog地图名字的话,mapwindow完全多余
[pre lang="javascript"]Scene_Map.prototype.createDisplayObjects = function() {
    this.createSpriteset();
    this.createWindowLayer();
    this.createAllWindows();
};

Scene_Map.prototype.callMenu = function() {
    SoundManager.playOk();
    SceneManager.push(Scene_Menu);
    Window_MenuCommand.initCommandPosition();
    $gameTemp.clearDestination();
    this._waitCount = 2;
};

Scene_Map.prototype.launchBattle = function() {
    BattleManager.saveBgmAndBgs();
    this.stopAudioOnBattleStart();
    SoundManager.playBattleStart();
    this.startEncounterEffect();
};

Scene_Map.prototype.start = function() {
    Scene_Base.prototype.start.call(this);
    SceneManager.clearStack();
    if (this._transfer) {
        this.fadeInForTransfer();
        $gameMap.autoplay();
    } else if (this.needsFadeIn()) {
        this.startFadeIn(this.fadeSpeed(), false);
    }
    this.menuCalling = false;
};

Scene_Map.prototype.terminate = function() {
    Scene_Base.prototype.terminate.call(this);
    if (!SceneManager.isNextScene(Scene_Battle)) {
        this._spriteset.update();
        SceneManager.snapForBackground();
    } else {
        ImageManager.clearRequest();
    }
    if (SceneManager.isNextScene(Scene_Map)) {
        ImageManager.clearRequest();
    }
    $gameScreen.clearZoom();
    this.removeChild(this._fadeSprite);
    this.removeChild(this._windowLayer);
    this.removeChild(this._spriteset);
};
[/pre]

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

评分

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

查看全部评分

老黄鸡

梦石
4
星屑
45707
在线时间
7948 小时
注册时间
2009-7-6
回帖
13338

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

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

点评

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

使用道具 举报

梦石
0
星屑
4058
在线时间
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.

在本版发帖返回顶部