“采集设备在x、y、z方向上的动作。
方法:
- accelerometer.getCurrentAcceleration
- accelerometer.watchAcceleration
- accelerometer.clearWatch
参数:
- accelerometerSuccess
- accelerometerError
- accelerometerOptions
accelerometer.getCurrentAcceleration |
|
说明:
加速计是检测设备在当前方向上所做相对运动变化(增、减量)的运动传感器。加速计可以检测沿X、Y和Z轴的三维运动。
加速度数据通过accelerometerSuccess回调函数返回。
支持的平台:
- Android
- BlackBerry WebWorks (OS 5.0或更高版本)
- iPhone
完整的范例:
iPhone的特异情况:
- iPhone没有获取在任何给定点当前加速度数据的概念。
- 你必须通过给定时间间隔查看加速度并获得数据。
- 因此,getCurrentAcceleration函数会返回从phoneGap watchAccelerometer调用开始后的最近一个返回值
accelerometer.watchAcceleration
|
|
说明:
加速计是检测设备在当前方向上所做相对运动变化(增、减量)的动作传感器。加速计可以检测沿X、Y和Z轴的三维运动。
accelerometer.watchAcceleration每隔固定时间就获取一次设备的当前加速度。每次取得加速度后,accelerometerSuccess回调函数会被执行。通过acceleratorOptions对象的frequency参数可以设定以毫秒为单位的时间间隔。
返回的watch
id是加速度计监视周期的引用,可以通过accelerometer.clearWatch调用该watch ID以停止对加速度计的监视。
支持的平台:
- Android
- BlackBerry WebWorks (OS 5.0或更高版本)
- iPhone
简单的范例:
完整的范例:
iPhone的特异情况:
- 在请求的时间间隔,PhoneGap将调用success回调指向的函数,并传递加速度计数据。
- 不过,PhoneGap将对设备的请求间隔时间限制为最小40ms,最大1000ms。
- 例如,如果你设定每隔3秒(3000毫秒)请求一次,PhoneGap仍然每隔1秒请求一次设备,但是每隔3秒才调用一次success回调函数。
watchID:由accelerometer.watchAcceleration返回的引用标识ID。
支持的平台:
- Android
- BlackBerry WebWorks (OS 5.0或更高版本)
- iPhone
完整的范例:
属性:
- x:在X轴的运动量,[0, 1]范围(数字类型)
- y:在Y轴的运动量,[0, 1]范围(数字类型)
- z:在Z轴的运动量,[0, 1]范围(数字类型)
- timestamp:以毫秒为单位的创建时间戳。(DOMTimeStamp类型)
说明:
这个对象是由phoneGap创建和填充,并由Acce这个对象是由PhoneGap创建和填充,并由Accelerometer的方法返回。
支持的平台:
- Android
- BlackBerry WebWorks (OS 5.0或更高版本)
- iPhone
完整的范例:
参数:
- acceleration: 在某一时刻的加速度(Acacceleration:在某一时刻的加速度。(Acceleration对象类型)
选项:
- frequency:多少毫秒获取一次Acceleration。(数字类型)(默认值:10000)
“采集设备在x、y、z方向上的动作。
方法:
- accelerometer.getCurrentAcceleration
- accelerometer.watchAcceleration
- accelerometer.clearWatch
参数:
- accelerometerSuccess
- accelerometerError
- accelerometerOptions
accelerometer.getCurrentAcceleration |
|
说明:
加速计是检测设备在当前方向上所做相对运动变化(增、减量)的运动传感器。加速计可以检测沿X、Y和Z轴的三维运动。
加速度数据通过accelerometerSuccess回调函数返回。
支持的平台:
- Android
- BlackBerry WebWorks (OS 5.0或更高版本)
- iPhone
完整的范例:
iPhone的特异情况:
- iPhone没有获取在任何给定点当前加速度数据的概念。
- 你必须通过给定时间间隔查看加速度并获得数据。
- 因此,getCurrentAcceleration函数会返回从phoneGap watchAccelerometer调用开始后的最近一个返回值
accelerometer.watchAcceleration
|
|
说明:
加速计是检测设备在当前方向上所做相对运动变化(增、减量)的动作传感器。加速计可以检测沿X、Y和Z轴的三维运动。
accelerometer.watchAcceleration每隔固定时间就获取一次设备的当前加速度。每次取得加速度后,accelerometerSuccess回调函数会被执行。通过acceleratorOptions对象的frequency参数可以设定以毫秒为单位的时间间隔。
返回的watch
id是加速度计监视周期的引用,可以通过accelerometer.clearWatch调用该watch ID以停止对加速度计的监视。
支持的平台:
- Android
- BlackBerry WebWorks (OS 5.0或更高版本)
- iPhone
简单的范例:
完整的范例:
iPhone的特异情况:
- 在请求的时间间隔,PhoneGap将调用success回调指向的函数,并传递加速度计数据。
- 不过,PhoneGap将对设备的请求间隔时间限制为最小40ms,最大1000ms。
- 例如,如果你设定每隔3秒(3000毫秒)请求一次,PhoneGap仍然每隔1秒请求一次设备,但是每隔3秒才调用一次success回调函数。
watchID:由accelerometer.watchAcceleration返回的引用标识ID。
支持的平台:
- Android
- BlackBerry WebWorks (OS 5.0或更高版本)
- iPhone
完整的范例:
属性:
- x:在X轴的运动量,[0, 1]范围(数字类型)
- y:在Y轴的运动量,[0, 1]范围(数字类型)
- z:在Z轴的运动量,[0, 1]范围(数字类型)
- timestamp:以毫秒为单位的创建时间戳。(DOMTimeStamp类型)
说明:
这个对象是由phoneGap创建和填充,并由Acce这个对象是由PhoneGap创建和填充,并由Accelerometer的方法返回。
支持的平台:
- Android
- BlackBerry WebWorks (OS 5.0或更高版本)
- iPhone
完整的范例:
参数:
- acceleration: 在某一时刻的加速度(Acacceleration:在某一时刻的加速度。(Acceleration对象类型)
选项:
- frequency:多少毫秒获取一次Acceleration。(数字类型)(默认值:10000)
分享到:
相关推荐
PhoneGap,API帮助文档翻译整理1-Accelerometer(加速度计)
Accelerometer 加速度计 Camera 相机 Capture 捕捉 Compass 指南针 Contacts 联系人 Device 设备 Events 活动 File 文件 Geolocation 地理位置 Media 媒体 Network 网络 Notification 通知 Storage 存储
Accelerometer 加速度计 Camera 相机 Capture 捕捉 Compass 指南针 Contacts 联系人 Device 设备 Events 活动 File 文件 Geolocation 地理位置 Media 媒体 Network 网络 Notification 通知 Storage 存储
phoneGap可以通过对象accelerometer得到手机的加速度,本项目示例可以学习怎么得到手机当前时间的加速度和定时间间隔周期性得到手机加速度
《Apress Beginning PhoneGap》 源码 PhoneGap-Accelerometer PhoneGap-Accelerometer-Image PhoneGap-Android-GWT-Hellworld PhoneGap-Camera PhoneGap-Compass PhoneGap-DeviceInfo 等
PhoneGap——Accelerometer【加速计】
PhoneGap开发必备 PhoneGap Mobile Application Development Cookbook Preface 1 Chapter 1: Movement and Location: Using the Accelerometer and Geolocation Sensors 7 Introduction 7 Detecting device ...
Use PhoneGap to build cross-platform mobile applications quickly and efficiently About This Book Build native mobile phone applications with HTML5, JavaScript, and CSS Incorporate smartphone ...
Table of Contents •Determining Whether the Device Is Ready •Retrieving Information About the Device •Creating a Persistent Navigation System ...•Extending PhoneGap with Plug-ins
Using the QuickConnect JavaScript API to perform tasks ranging from vibrating the phone to accessing the accelerometer and GPS location data Accessing native iPhone functionality using the PhoneGap ...
However, there are still two things that it cannot do: it can’t access the device features and hardware (e.g., geolocation, accelerometer, sound, and vibration) and it can’t be submitted to the ...
#Rikulo Gap 是 Dart 中移动框架(又名 PhoneGap)的桥接实现。 它使开发人员能够使用 HTML、CSS 和 Dart 访问多个移动平台的本机设施。Rikulo Gap 在 Apache 2.0 许可下分发。 ##从 Dart Pub 存储库安装将此添加到...
With the help of straightforward, real-world examples, you’ll learn to build apps from the Cordova CLI and to make use of native device features like the camera and accelerometer. You’ll learn ...
Use PhoneGap to hook into advanced Android features -- including the accelerometer, geolocation, and alerts Test and debug your app on the Web under load with real users, and then submit the ...
Use PhoneGap to hook into advanced Android features — including the accelerometer, geolocation, and alerts Test and debug your app on the Web under load with real users, and then submit the finished ...
You’ll find guidelines for converting your product into a native iPhone app using the free PhoneGap framework. And you’ll learn why releasing your product as a web app first helps you find, fix, ...
3. Accelerometer 4. JQuery 5. JQuery plugin example JQuery 插件示例使用: JQuery 插件骰子可以在任何网页中使用。 使用 JQuery 类骰子,我们可以向指定的选择器启动一个动画骰子对象。 var dice1 = $("#dice...