레퍼런스 deviceShaken()

deviceShaken()

The deviceShaken() function is called when the device total acceleration changes of accelerationX and accelerationY values is more than the threshold value. The default threshold is set to 30. The threshold value can be changed using setShakeThreshold().

예제

// Run this example on a mobile device
// Shake the device to change the value.

let value = 0;
function draw() {
fill(value);
rect(25, 25, 50, 50);
describe(`50-by-50 black rect in center of canvas.
turns white on mobile when device shakes`);
}
function deviceShaken() {
value = value + 5;
if (value > 255) {
value = 0;
}
}
Notice any errors or typos? Please let us know. Please feel free to edit src/events/acceleration.js and open a pull request!

관련 레퍼런스

Complete your gift to make an impact