http://www.ivangabriele.com/cordova-detecting-shaking/
我正在学习在javascript中编写摇动功能。但我不知道如何检测和计算用户所做的震动次数,有人可以帮我一把吗?
shake.startWatch(onShake);
function onShake()
{
alert('Shook');
}
// Stop watching for shaking event
shake.stopWatch();
答案 0 :(得分:0)
这是一种可以计算震动的方法。
shake.startWatch(onShake);
var count = 0;
function onShake()
{
alert('Shook');
count++ //increases count by 1 each time the function is called.
}
// Stop watching for shaking event
shake.stopWatch();