Project1
标题:
设置移动路线的代码
[打印本页]
作者:
写给妖精的情诗
时间:
7 天前
标题:
设置移动路线的代码
昨天我在搞设置移动路线,因为需要在脚本框设置而测试出了下面这些东西。
就是 本事件的 $gameMap.event(this.eventId()) 或者是玩家的 $gamePlayer 这两个代码,
跟 Game_Character.prototype.processMoveCommand = function(command) 里面的那些代码拼接在一起,再加上 this.wait(30); 这个等待多少帧就好了。
拼接的时候,由于已经有 $gameMap.event(this.eventId()) 或者是 $gamePlayer 了,那些 this. 就不需要了。
2025-05-30 105919.png
(60.35 KB, 下载次数: 3)
下载附件
保存到相册
7 天前
上传
//下面这两个移动速度和移动频率好像不起作用,可能是写法搞错了,现在是依靠等待多少帧来调整速度的。
//$gameMap.event(this.eventId()).setMoveSpeed(6);
//$gameMap.event(this.eventId()).setMoveFrequency(6);
//$gamePlayer.moveStraight(8); //这个是玩家移动
$gameMap.event(this.eventId()).moveStraight(4); //这个是本事件移动
this.wait(30); //这个等待好像是必须的,没有这个等待,移动会快的要死
//上面这样的是在事件指令的脚本框这里写的,下面这样的可以直接放在事件页、自主移动、自定义、路线的左上角那里。
//this.moveStraight(4);
//在rmmz_objects.js和rpg_objects.js搜索Game_Character.prototype.processMoveCommand可以找到更多的设置移动指令
上面这个用法好像是一个投机取巧的方法,不是 rpg maker 原始的用法,但是好像可以拿来用作像素移动、点移动之类的东西。
就是按下WSAD键就上下左右移动,也可以设置哪几个按键就左上、左下、右上、右下移动。
至于点击鼠标的移动这个,在 rmmz_core.js 找到下面这段代码,把 document.addEventListener("mousedown", this._onMouseDown.bind(this)); 注释掉就能让原本的点击鼠标移动失效了。
TouchInput._setupEventHandlers = function() {
const pf = { passive: false };
document.addEventListener("mousedown", this._onMouseDown.bind(this));
document.addEventListener("mousemove", this._onMouseMove.bind(this));
document.addEventListener("mouseup", this._onMouseUp.bind(this));
document.addEventListener("wheel", this._onWheel.bind(this), pf);
document.addEventListener("touchstart", this._onTouchStart.bind(this), pf);
document.addEventListener("touchmove", this._onTouchMove.bind(this), pf);
document.addEventListener("touchend", this._onTouchEnd.bind(this));
document.addEventListener("touchcancel", this._onTouchCancel.bind(this));
window.addEventListener("blur", this._onLostFocus.bind(this));
};
但是上面这段代码复制到脚本框去好像不行,说不定还有其他的代码可以这样搞。
这个问题以及怎么让鼠标点击之后让主角移动按照 $gamePlayer.moveStraight(8); 这类移动,我现在没有这个需求,现在就没空去管了。
另外,在
https://www.rpgmaker-script-wiki.xyz/mzscriptwiki.php
这里还有下面这段脚本好像是设置移动路线的,可能就是 rpg maker 原始的用法,但是好像有点麻烦。
移動ルートの設定
this.character(キャラクターID).forceMoveRoute({
"list":[{"code":コードID,"parameters":パラメータ}
{"code":コードID,"parameters":パラメータ}],
//ルート入力終了 *必須
{"code":0}],
//動作を繰り返す
"repeat":true か false,
//移動できない場合は飛ばす
"skippable":true か false,
//完了までウェイト
"wait":true か false
})
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1