Skip to main content

clampCamera 限制摄像机边界

clampCamera

类型: MethodDeclaration

所属类: CommandFunctionList

定义位置: command.ts

描述

限制摄像机边界

参数

参数名类型描述默认值
\{ left, top, right, bottom, \}{
	left: 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);
top: 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);
right: 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);
bottom: 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

源代码

位置: 第 8275 行

protected clampCamera({
left,
top,
right,
bottom,
}: {
left: number | VariableGetter;
top: number | VariableGetter;
right: number | VariableGetter;
bottom: number | VariableGetter;
}): CommandFunction {
const getLeft = Command.compileNumber(left, 0, -1000, 1000);
const getTop = Command.compileNumber(top, 0, -1000, 1000);
const getRight = Command.compileNumber(right, 0, -1000, 1000);
const getBottom = Command.compileNumber(bottom, 0, -1000, 1000);
return () => {
Camera.clamp(getLeft(), getTop(), getRight(), getBottom());
return true;
};
}

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