加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
MV加入了一堆功能虽然提升了利用度,但是效率仍然是低的令人发指。除去JS不讨论,其中最浪费运行效率的是不该创建的窗口创建,以及无用的对象在不停的update,于是在需要的时候update,删除不必要的窗口是可行的方案。
举个例子:当你使用Yanfly的ATB插件与Mog 的Bhud插件时,statusWindow就是完全不需要的窗口,而Yanfly的ATB仍然在不停的更新ATB条,但是你又看不见,因为mog直接将其透明度调到0.所以这是一个极为浪费的过程,并且默认启用ActorCommand,PartyCommand直接被无视掉了,方法就是删掉与statuswindow及PartyCommand相关的东西,举个例子: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() { };
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() {
};
战斗中隐藏的窗口不需要刷新(前提是你不需要),等到显现出来时才需要,所以:
Window_Base.prototype.update = function() { if ($gameParty.inBattle() && !this.visible) return; Window.prototype.update.call(this); this.updateTone(); this.updateOpen(); this.updateClose(); this.updateBackgroundDimmer(); };
Window_Base.prototype.update = function() {
if ($gameParty.inBattle() && !this.visible) return;
Window.prototype.update.call(this);
this.updateTone();
this.updateOpen();
this.updateClose();
this.updateBackgroundDimmer();
};
如果你不用鼠标功能的话,为什么要留着算力给touchinput更新呢?
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(); };
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();
};
既然鼠标不让用,留着商店里按的图标也没意思了:
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); };
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);
};
使用mog地图名字的话,mapwindow完全多余
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); };
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);
};
抛砖引玉,有什么想法在更新 |