控制器#
介绍#
IQ(第二代)Brain 可以连接到 IQ(第二代)或 IQ(第一代)控制器。两个控制器都配有两个模拟摇杆和多个按钮,Brain 可以使用它们来检测动作和按压。
For the examples below, the configured Distance Sensors will be named Controller
, and will be used in all subsequent examples throughout this API documentation when referring to Controller class methods.
以下是可用方法的列表:
操作 - 启用或禁用控制器。
RemoteControlCodeEnabled – 启用或禁用控制器配置的操作。
Getters——从控制器操纵杆和按钮返回值。
回调——通过回调方法与控制器交互。
构造函数——手动初始化控制器。
controller – 创建一个控制器。
行动#
RemoteControlCodeEnabled#
RemoteControlCodeEnabled
is a variable that can be set to a Boolean that enables or disables Controller configured actions from the Devices menu. The controller is enabled by default. It can be set to either of the following:
true
— Enable Controller configured actions.false
— Disable Controller configured actions.
Usage:
RemoteControlCodeEnabled = false;
// Example coming soon
吸气剂#
pressing#
pressing
returns an integer indicating whether a specific button on the controller is currently being pressed. This method must be called on a specific button object, such as ButtonEDown
(see full list of button objects below).
1
- The specified button is being pressed.0
- The specified button is not being pressed.
用法:
十个可用按钮对象之一可用于此方法,如下所示:
按钮 |
命令 |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

参数 |
描述 |
---|---|
该方法没有参数。 |
// Example coming soon
position#
position
returns the position of the joystick’s specified axis as an integer from –100 to 100, representing a percentage. This method must be called on a specific axis object, such as AxisA
(see full list of axis objects below).
用法:
可以使用此方法的四个可用轴之一,如下所示:
轴 |
命令 |
---|---|
|
|
|
|
|
|
|
|

参数 |
描述 |
---|---|
该方法没有参数。 |
// Example coming soon
打回来#
pressed#
pressed
registers a function to be called when a specific button on the controller is pressed. This method must be called on a specific button object, such as ButtonEDown
– (see full list of button objects below).
用法:
十个可用按钮对象之一可用于此方法,如下所示:
按钮 |
命令 |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
范围 |
描述 |
---|---|
|
按下指定按钮时调用的回调函数。 |
// Example coming soon
released#
released
registers a function to be called when a specific button on the controller is released. This method must be called on a specific button object, such as ButtonEDown
– (see full list of button objects below).
用法:
十个可用按钮对象之一可用于此方法,如下所示:
按钮 |
命令 |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
范围 |
描述 |
---|---|
|
当指定按钮被释放时调用的回调函数。 |
// Example coming soon
changed#
changed
registers a function to be called when the joystick’s position changes. This method must be called on a specific axis object, such as AxisA
(see full list of axis objects below).
用法:
可以使用此方法的四个可用轴之一,如下所示:
轴 |
命令 |
---|---|
|
|
|
|
|
|
|
|

参数 |
描述 |
---|---|
|
当指定轴的位置发生变化时调用的回调函数。 |
// Example coming soon
构造函数#
controller#
controller
creates a controller object.
Usage:
controller Controller = controller();
范围 |
描述 |
---|---|
该方法没有参数。 |
// Example coming soon