我觉得计时器随着地图一起被放大了。在 MV 中,计时器精灵位于地图的精灵组(spriteset)内部,因此当缩放以玩家为中心放大一切时,位于右上角的计时器会被移出屏幕。如果把它从精灵组中移除,使其不受缩放影响呢?将此代码保存为 js/plugins 目录下的一个新 .js 文件,并在插件管理器中启用它:
(function() {
var _Scene_Map_createDisplayObjects = Scene_Map.prototype.createDisplayObjects;
Scene_Map.prototype.createDisplayObjects = function() {
_Scene_Map_createDisplayObjects.call(this);
var timer = this._spriteset._timerSprite;
if (timer) {
this._spriteset.removeChild(timer);
this.addChildAt(timer, this.children.indexOf(this._windowLayer));
}
};
})();
我怀疑居中不良的问题主要出现在地图边缘附近。该插件以屏幕上玩家的位置为中心进行缩放。因此,一旦相机在地图边缘停止滚动且玩家偏离中心行走,即使地图上仍有未显示的区域,缩放也会让玩家保持在非中心位置。在 ED5_ScrollWheelZoom.js 的 updateZoom 函数内部,尝试替换以下行:
const playerX = $gamePlayer.screenX();
const playerY = $gamePlayer.screenY();
$gameScreen.setZoom(playerX, playerY, zoom);
改为以下内容,以便选择将玩家置于屏幕中央的缩放点,仅在该操作会导致超出地图边缘时才限制缩放:
const tw = $gameMap.tileWidth();
const th = $gameMap.tileHeight();
let zoomX = $gamePlayer.scrolledX() * tw + tw / 2;
let zoomY = $gamePlayer.scrolledY() * th + th / 2;
if (zoom > 1.001) {
zoomX = (zoomX * zoom - Graphics.width / 2) / (zoom - 1);
zoomY = (zoomY * zoom - Graphics.height / 2) / (zoom - 1);
zoomX = Math.min(Math.max(zoomX, 0), Graphics.width);
zoomY = Math.min(Math.max(zoomY, 0), Graphics.height);
}
$gameScreen.setZoom(zoomX, zoomY, zoom);
然后在 setDestination 函数更下方的位置,将 zoomX 和 zoomY 的行更改为以下内容,以便当缩放点落在地图边缘的 0 处时,“点击移动”仍能正确对齐:
const zoomX = $gameScreen.zoomX();
const zoomY = $gameScreen.zoomY();
你的极光展示命令是否使用了屏幕模式?这是插件的默认设置,屏幕模式会将极光固定在屏幕上。因此,当缩放围绕玩家移动地图时,极光会保持在屏幕上的固定位置,看起来像是在跟随你。地图模式则将它们放置在地图像素中,使它们随地图一起缩放和平移:
DRAGON_NorthernLights:show <mode: "map", x: 0, y: 0, width: 0, height: 0>
在地图模式中,x 和 y 从地图的左上角开始计数,而宽度或高度设为 0 则表示使用屏幕尺寸。如果你的地图比屏幕大,我建议将宽度设置为地图的瓦片数乘以 48。