控制器#
要使控制器命令出现在 VEXcode 中,必须首先将 V5 控制器连接到 VEXcode V5。
请参阅以下文章以了解更多信息:
初始化控制器类#
要在项目中使用控制器,请首先按如下方式初始化它:
# Create a new object "controller" with the Controller class.
controller = Controller()
This controller object will be used in all subsequent examples throughout this API documentation when referring to Controller class methods and attributes.
The Controller class comes with three pre-defined attributes, though the screen attribute is only available if you are using a V5 Controller:
axis- Allows you to detect movements in the Controller’s joysticks and assign functions to axes events.button- Allows you to detect button presses and assign functions to button events on the Controller.screen- V5 Controller Only. Enables you to display text and draw images on the V5 Controller’s screen.
类方法#
In addition to its attributes, the Controller has access to the rumble method.
controller.rumble()#
The controller.rumble(pattern) method sends a rumble string to the V5 controller.
范围 |
描述 |
|---|---|
|
A pattern using |
**返回:**无
# Rumble the V5 Controller to the pattern short-short-long-long.
controller.rumble('..--')