Total Pageviews

Tuesday, May 20, 2014

មើលអំពី Deveice Status

Event InputDeviceStatus
សំរាប់ events មួយនេះត្រូវបាន indicates ថា input device’s status ត្រូវបានផ្លាស់ប្តូរ ដូចជានៅពេល​ input device has been connected or disconnected ចេញពី system ឬនៅពេល device’s configuration ត្រូវបានផ្លាស់ប្តូរ។ ហើយ event នេះជាមានតាមខាងក្រោមះ
១. យកការគ្រប់គ្រង់ touchscreen ចេញនៅពេល gamepad or joystick ត្រូវបានរកឃើញ
២. ផ្តល់នៅអ្នកលេង២នាក់នៅជំរើសដែលបើសិនជាហ្គេមទី២ត្រូវបានរកឃើញ
៣. វានឹងឈប់នៅហ្គេមនៅពេល play’s game controller ត្រូវបាន​ disconnected
នេះជា Properties របស់វា
event.connectionStateChanged វានឹងដាក់ទៅជា true បើសិនជា​ input device’s connection ជាមួយនឹង system ត្រូវបានផ្លាស់ប្តូរដូចជាពី connected to disconnected or disconnected to connected។ អ្នកអាចចូលទៅវា input devices current connection state តាមរយះ event.device.connectionState property។​ បើដាក់វាជា false បើសិនជា input device’s current connection ជាមួយនឹង system មិនត្រូវបានប្តូរ។ វាមានន័យថា ផ្នែកខ្លះនៃ​ input device’s status ត្រូវបានផ្លាស់ប្តូរ។
សូមមើលកូដះ
-- Called when the status of an input device has changed.
local function onInputDeviceStatusChanged( event )
    if event.connectionStateChanged then
        print( event.device.displayName .. ": " .. event.device.connectionState )
    end
end

-- Set up the above function to receive input device status change events.
Runtime:addEventListener( "inputDeviceStatus", onInputDeviceStatusChanged )
event.device ផ្តល់នៅការចូលទៅកាន់ InoutDevice ដែល status ត្រូវបានផ្លាស់ប្តូរ
property នេះនឹងមិនដែលជា nil សំរាប់ inputDeviceStatus event ទេ
event.name វាជា String “inputDeviceStatus”
event.reconfigured បើដាក់វាជា true បើសិនជា input device ត្រូវបាន reconfigured, ដូចដែលនៅពេល axis inputs ត្រូវបានបន្ថែម ឬលុបចេញពី device។ ដែល displayName ត្រូវបានផ្លាស់ប្តូរ ឬក៏ការ configuration ត្រូវបានប្តូរ។ វាអាច​ចូលបានដែល​ configuration បានផ្លាស់ប្តូរតាមរយះ event.device property។ បើដាក់វាជា false បើសិនជា​ input device’s configuration មិនត្រូវបានផ្លាស់ប្តូរ។ វាមានន័យថា ផ្នែកខ្លះរបស់ input device’s status ត្រូវបានប្តូរ ដូចជា connected or disconnected ចេញពី system
ចំណាំះ សំរាប់ android វាជា common សំរាប់​ operating system ក្នុងការប្តូរ androidDeviceId នៃ input device ដែលត្រូវបានភ្ជាប់ឡើងវិញទៅកាន់ system បន្ទាប់ពីត្រូវបាន disconnected
សូមមើលកូដះ
-- Called when the status of an input device has changed.
local function onInputDeviceStatusChanged( event )
    if event.reconfigured then
        print( event.device.displayName .. " has been reconfigured." )
    end
end

-- Set up the above function to receive input device status change events.
Runtime:addEventListener( "inputDeviceStatus", onInputDeviceStatusChanged )

សូមមើលកូដះ
-- Called when one input device's status has been changed.
local function onInputDeviceStatusChanged( event )
    -- Handle the input device change.
end
-- Add the input device status event listener.

Runtime:addEventListener( "inputDeviceStatus", onInputDeviceStatusChanged )

No comments:

Post a Comment