system.activate()

类型 函数
system.*
返回值
修订 版本 2024.3703
关键词 多点触控
另请参阅 system.deactivate()

概述

激活系统级功能,例如 "multitouch"(多点触控)。类似地,您可以使用 system.deactivate() 禁用某个功能。

默认情况下,多点触控功能是禁用的,因此您必须始终通过此方法首先将其激活。

语法

system.activate( feature )
feature (必填)

字符串. 要激活的系统功能。目前,唯一支持的值包括:

示例

-- The following sample activates multitouch and creates a touch listener for a graphic
-- This displays the location, phase, and touch ID of each touch event

system.activate( "multitouch" )
 
local bg = display.newRect( 0, 0, 320, 480 )
local output = native.newTextBox( 0, 20, 320, 240 )
output.size = 12
 
local function showTouch( event )
    -- Display the event info on the screen
    output.text = output.text .. "\nPhase: " .. event.phase
    output.text = output.text .. "\n(" .. event.x .. "," .. event.y .. ")"
    output.text = output.text .. "\nId: " .. tostring( event.id )
end
 
bg:addEventListener( "touch", showTouch )