C++#
本指南详细介绍了如何在 VEXcode EXP 中使用 C++ 命令。您将学习如何阅读和理解每个命令,并了解其详尽的描述、参数和使用示例。
启用 VEX 命名空间#
In C++, classes from the VEX library are accessed using the vex::
namespace prefix, such as vex::color
. However, you can simplify your code by enabling the entire VEX namespace at the beginning of your file. To do this, add the statement using namespace vex;
at the top of your project. Once enabled, you can directly use VEX classes without the vex::
prefix, allowing you to write color instead of vex::color
.
了解命令条目#
API 参考中的每个命令条目都包含以下组件:
命令名称和签名:这是命令及其参数的名称。
描述:对该命令功能的简要说明。
阻塞/非阻塞:表示命令是否等待完成后再转到下一个命令。
参数表:列出并描述该命令接受的参数。
返回:描述命令返回的内容(如果适用)。
示例:提供示例代码片段,演示如何使用该命令。
命令输入示例#
传动系统.设置旋转()#
The Drivetrain.setRotation()
command sets the rotation for the Drivetrain.
参数 |
描述 |
---|---|
价值 |
用于旋转的新值。 |
单位 |
Optional. A valid rotationUnit. The default is |
**返回:**无。
// Set the value of rotation to 180 degrees.
Drivetrain.setRotation(180);