跳到主要内容

setMovementSpeed 设置移动速度

setMovementSpeed

类型: MethodDeclaration

所属类: CommandFunctionList

定义位置: command.ts

描述

设置移动速度

参数

参数名类型描述默认值
\{ actor, property, base, factor, \}{
	actor: [`ActorGetter`](https://github.com/Open-Yami-Community/open-yami-doc/blob/main/i18n/zh/docusaurus-plugin-content-docs/current/script/yami/yami.command.d.ts#L152);
property: "base" \| "factor" \| "factor-temp";
base?: number \| [`VariableGetter`](https://github.com/Open-Yami-Community/open-yami-doc/blob/main/i18n/zh/docusaurus-plugin-content-docs/current/script/yami/yami.command.d.ts#L87);
factor?: number \| [`VariableGetter`](https://github.com/Open-Yami-Community/open-yami-doc/blob/main/i18n/zh/docusaurus-plugin-content-docs/current/script/yami/yami.command.d.ts#L87);
} | - | - |

返回值

类型: CommandFunction

源代码

位置: 第 6571 行

protected setMovementSpeed({
actor,
property,
base,
factor,
}: {
actor: ActorGetter;
property: "base" | "factor" | "factor-temp";
base?: number | VariableGetter;
factor?: number | VariableGetter;
}): CommandFunction {
const getActor = Command.compileActor(actor);
switch (property) {
case "base": {
const getBase = Command.compileNumber(base!, 0, 0, 32);
return () => {
getActor()?.navigator.setMovementSpeed(getBase());
return true;
};
}
case "factor": {
const getFactor = Command.compileNumber(factor!, 0, 0, 4);
return () => {
getActor()?.navigator.setMovementFactor(getFactor());
return true;
};
}
case "factor-temp": {
const getFactor = Command.compileNumber(factor!, 0, 0, 4);
return () => {
getActor()?.navigator.setMovementFactorTemp(getFactor());
return true;
};
}
}
}

文档生成时间:2026/2/1 16:51:39