Accelerometer with creator

Accelerometer with creator
0.0 0

#1

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.


#2

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

},

#3

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!