| 赞 | 4 |
| VIP | 0 |
| 好人卡 | 0 |
| 积分 | 14 |
| 经验 | 0 |
| 最后登录 | 2026-5-22 |
| 在线时间 | 159 小时 |
Lv3.寻梦者
- 梦石
- 0
- 星屑
- 1444
- 在线时间
- 159 小时
- 注册时间
- 2025-2-15
- 帖子
- 74
|
本帖最后由 写给妖精的情诗 于 2026-3-31 09:55 编辑
Game_Player.prototype.center = function(x, y) {
return $gameMap.setDisplayPos(x - this.centerX(), y - this.centerY());
};
虽然是几年前的帖子,但是我刚好也是搜索这个问题找过来的,就留个回复吧。
上面这段rmmz_objects.js的代码是玩家移动或者场所移动的时候,播放器始终以玩家为中心所以需要重新定位。
X和Y应该是玩家的坐标,centerX是下面这段代码,screenTileX这个东西是屏幕的宽度,
中心点centerX减去半个屏幕($gameMap.screenTileX() - 1) / 2;就是最左边显示的地方,因为上面这段是在左上角定位的。
Game_Player.prototype.centerX = function() {
return ($gameMap.screenTileX() - 1) / 2;
};

//把左上角移到本事件的坐标,然后再减去半个屏幕的X轴和Y轴,就可以让本事件显示在屏幕中间了。
$gameMap.setDisplayPos($gameMap.event(this.eventId()).x - $gamePlayer.centerX(), $gameMap.event(this.eventId()).y - $gamePlayer.centerY()); |
|