Total Pageviews

Saturday, May 31, 2014

នេះជា Type Runtime របស់ Corona SDK

នេះជា Type Runtime របស់ Corona SDK
នៅពេល Runtime class inherits ពី EventListener។ វាជា singleton class meaning there is only one instance accessible តាមរយះ global Runtime
នេះជាហ្វាំងសិនរបស់វា
Runtime:hasEventSource()
ប្រើសំរាប់កំនត់បើសិនជា device is capable ក្នុងការផ្តល់នៅ events ដែលមាន event source ដូចជា accelerometer or gyroscope។ ត្រូវហៅហ្វាំងសិននេះមុន Runtime:addEventListener() function។ សំរាប់ហ្វាំងសិននេះត្រលប់ជា true បើសិនជាមាន event source។ មានន័យថាវាប្រើ Runtime:addEventListener() ក្នុងការ​ handle its events។ វានឹងត្រឡប់ជា false បើសិនជា event source មិនមាន
Syntax: runtime:hasEventSource (eventSourceName)
eventSourceName (តំរូវការ) ​​​​​​​​​​​​​​​​​​​​​​​វាជា String ដែលជាឈ្មោះរបស់ event source ក្នុងការ check for the existence ដូចជា accelerometer or gyroscope
សូមមើលកូដះ
if Runtime:hasEventSource( "gyroscope" ) then
    Runtime:addEventListener( "gyroscope", myListener )

end

No comments:

Post a Comment