给出参考用的代码吧
var ULDS = ULDS || {};
ULDS.JitterFix = {};
ULDS.JitterFixPlus = 1 / 1000000; // 误差值
ULDS.JitterFix.Parameters = PluginManager.parameters('JitterFix');
ULDS.JitterFix.TileSize = Number(ULDS.JitterFix.Parameters["Tile Size"]) || 48;
// 修改地图的显示坐标
Game_Map.prototype.displayX = function() {
return Math.floor(this._displayX * ULDS.JitterFix.TileSize) / ULDS.JitterFix.TileSize;
};// 消除移动带来的误差,消除小数
Game_Map.prototype.displayY = function() {
return Math.floor(this._displayY * ULDS.JitterFix.TileSize) / ULDS.JitterFix.TileSize;
};
Game_Map.prototype.adjustX = function(x) {
if (this.isLoopHorizontal() && x < (this.displayX() - (this.width() - ULDS.JitterFix.TileSize) / 1000000)) {
x -= this.displayX() + this.width()-ULDS.JitterFixPlus;
} else {
x -= this.displayX();
}
return x; // 消除精度误差
};
Game_Map.prototype.adjustY = function(y) {
if (this.isLoopVertical() && y < (this.displayY() - (this.height() - ULDS.JitterFix.TileSize) / 1000000)) {
y -= this.displayY() + this.height()-ULDS.JitterFixPlus;
} else {
y -= this.displayY();
}
return y;
};
// 同步事件的显示坐标
Game_Map.prototype.displayX = function() {
return Math.floor(this._displayX * ULDS.JitterFix.TileSize) / ULDS.JitterFix.TileSize;
};
Game_Map.prototype.displayY = function() {
return Math.floor(this._displayY * ULDS.JitterFix.TileSize) / ULDS.JitterFix.TileSize;
};
// 修改 Game_Event 中的事件显示坐标
Game_Event.prototype.screenX = function() {
// 修正事件的显示位置,确保与地图完全对齐
return (this._realX +0.5- $gameMap.displayX()) * ULDS.JitterFix.TileSize;
};
Game_Event.prototype.screenY = function() {
// 同样,修正事件的显示位置,确保与地图完全对齐
return (this._realY +1- $gameMap.displayY()) * ULDS.JitterFix.TileSize;
};
// 更新事件的屏幕坐标
Game_Event.prototype.updateScreenPosition = function() {
// 直接设置事件的显示坐标,保持与地图位置绑定
this._screenX = this.screenX();
this._screenY = this.screenY();
};
var ULDS = ULDS || {};
ULDS.JitterFix = {};
ULDS.JitterFixPlus = 1 / 1000000; // 误差值
ULDS.JitterFix.Parameters = PluginManager.parameters('JitterFix');
ULDS.JitterFix.TileSize = Number(ULDS.JitterFix.Parameters["Tile Size"]) || 48;
// 修改地图的显示坐标
Game_Map.prototype.displayX = function() {
return Math.floor(this._displayX * ULDS.JitterFix.TileSize) / ULDS.JitterFix.TileSize;
};// 消除移动带来的误差,消除小数
Game_Map.prototype.displayY = function() {
return Math.floor(this._displayY * ULDS.JitterFix.TileSize) / ULDS.JitterFix.TileSize;
};
Game_Map.prototype.adjustX = function(x) {
if (this.isLoopHorizontal() && x < (this.displayX() - (this.width() - ULDS.JitterFix.TileSize) / 1000000)) {
x -= this.displayX() + this.width()-ULDS.JitterFixPlus;
} else {
x -= this.displayX();
}
return x; // 消除精度误差
};
Game_Map.prototype.adjustY = function(y) {
if (this.isLoopVertical() && y < (this.displayY() - (this.height() - ULDS.JitterFix.TileSize) / 1000000)) {
y -= this.displayY() + this.height()-ULDS.JitterFixPlus;
} else {
y -= this.displayY();
}
return y;
};
// 同步事件的显示坐标
Game_Map.prototype.displayX = function() {
return Math.floor(this._displayX * ULDS.JitterFix.TileSize) / ULDS.JitterFix.TileSize;
};
Game_Map.prototype.displayY = function() {
return Math.floor(this._displayY * ULDS.JitterFix.TileSize) / ULDS.JitterFix.TileSize;
};
// 修改 Game_Event 中的事件显示坐标
Game_Event.prototype.screenX = function() {
// 修正事件的显示位置,确保与地图完全对齐
return (this._realX +0.5- $gameMap.displayX()) * ULDS.JitterFix.TileSize;
};
Game_Event.prototype.screenY = function() {
// 同样,修正事件的显示位置,确保与地图完全对齐
return (this._realY +1- $gameMap.displayY()) * ULDS.JitterFix.TileSize;
};
// 更新事件的屏幕坐标
Game_Event.prototype.updateScreenPosition = function() {
// 直接设置事件的显示坐标,保持与地图位置绑定
this._screenX = this.screenX();
this._screenY = this.screenY();
};
|