控制器#

初始化控制器类#

The controller constructor creates a controller object.

// Create a new object "Controller" with the Controller class.
controller 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:

  • - 允许您检测控制器操纵杆的运动并为轴事件分配功能。

  • 按钮 - 允许您检测按钮按下并为控制器上的按钮事件分配功能。

  • 屏幕 - 仅限 V5 控制器。 使您能够在 V5 控制器的屏幕上显示文本和绘制图像。

属性

类方法#

In addition to its attributes, the Controller has access to the rumble method if using a V5 Controller.

rumble()#

The rumble(pattern) command rumbles the controller by a pattern defined by the parameter, pattern. Dots equal short rumbles, dashes equal long rumbles, and space equals a pause.

范围

描述

图案

一种使用“。”和“-”表示短隆隆声和长隆隆声的模式。

**返回:**无。

controller Controller1 = controller(primary);

// Rumble the Controller to the pattern short-short-long-long.
Controller.rumble('..--');