rpg_objects以下代碼主要是處理按鍵或是鼠標輸入時的移動
[pre lang="javascript" line="7592"]Game_Player.prototype.moveByInput = function() {
if (!this.isMoving() && this.canMove()) {
var direction = this.getInputDirection();
if (direction > 0) {
$gameTemp.clearDestination();
} else if ($gameTemp.isDestinationValid()){
var x = $gameTemp.destinationX();
var y = $gameTemp.destinationY();
direction = this.findDirectionTo(x, y);
}
if (direction > 0) {
this.executeMove(direction);
}
}
};
Game_Player.prototype.canMove = function() {
if ($gameMap.isEventRunning() || $gameMessage.isBusy()) {
return false;
}
if (this.isMoveRouteForcing() || this.areFollowersGathering()) {
return false;
}
if (this._vehicleGettingOn || this._vehicleGettingOff) {
return false;
}
if (this.isInVehicle() && !this.vehicle().canMove()) {
return false;
}
return true;
};[/pre]
由 if (!this.isMoving() && this.canMove())
我們可以知道判定是否可以移動是由:玩家不在移動中 和 玩家可以移動
兩個部分組成
所以我們可以在 玩家可以移動這個地方再另外加入一項條件
就可以阻止玩家移動
將以下代碼加入plugin
[pre lang="javascript"]Game_Player.prototype.canMove = function() {
if ($gameMap.isEventRunning() || $gameMessage.isBusy()) {
return false;
}
if (this.isMoveRouteForcing() || this.areFollowersGathering()) {
return false;
}
if (this._vehicleGettingOn || this._vehicleGettingOff) {
return false;
}
if (this.isInVehicle() && !this.vehicle().canMove()) {
return false;
}
if ($gameSwitches.value(1)) {
return false;
}
return true;
};[/pre]
在一號開關開啟時,玩家就無法移動
要更改開關號碼就把$gameSwitches.value(1)的1改成其他開關