Accelerometer with creator

Does this work with creator?

I have an example from cocos js but I cannot seem to get it to work on android in creator.

OK I Finally got this working. For Anyone else interested here is the code

onLoad: function () {

    cc.inputManager.setAccelerometerEnabled(true);
    cc.systemEvent.on(cc.SystemEvent.EventType.DEVICEMOTION, this.onDeviceMotionEvent, this);

},

onDeviceMotionEvent (event) {

    var x = event.acc.x;
    var y = event.acc.y;

// use as you wish

},
2 Likes

My Typescript is screaming like hell


But it works! Thanks mate!

Edit: this works fantastic for mobile. You really saved my day. Thanks for sharing!