类型 布尔值 对象 InputDevice 修订版 版本 2024.3703 关键字 设备、输入、震动、canVibrate 另请参阅 object:vibrate()
确定输入设备是否支持振动/隆隆反馈。这是通常由游戏手柄支持的一项功能。
如果支持振动,则会返回 true。这意味着你可以调用输入设备的 vibrate() 函数。
如果输入设备不支持振动反馈或者操作系统不支持,则返回 false。
-- Called when a key event has been received
local function onKeyEvent( event )
-- Vibrate the gamepad if its 'A' button was pressed
if ( event.keyName == "buttonA" ) and ( event.phase == "down" ) then
if event.device and event.device.canVibrate then
event.device:vibrate()
end
end
end
-- Set up the above function to receive key events
Runtime:addEventListener( "key", onKeyEvent )