Hello, I’m utilizing DEVICEMOTION with v2.0.10 CC undertaking. I exploit the next code, nevertheless the node I’m making an attempt to maneuver with devicemotion is unresponsive when examined on a cell machine with tilt.
cc.systemEvent.setAccelerometerEnabled(true);
cc.systemEvent.on(cc.SystemEvent.EventType.DEVICEMOTION, this.onDeviceMotionEvent, this);
onDeviceMotionEvent: perform (occasion) {
occasion.acc.x = this.ballAccel.x;
occasion.acc.y = this.ballAccel.y;
cc.log(occasion.acc.x + " " + occasion.acc.y);
},
Despite the fact that occasion.acc.x and .y don’t equal 0, the code doesn’t work appropriately.
You may check with the instance instances which have been created by new a undertaking, click on Examples tab . After creation, the DeviceMotion instance is underneath asset->cases->03_gameplay->01_player_control->DeviceMotion
Really it’s best to alter the goal motion on the replace perform.
I’ve the motion adjusted within the replace perform with the code
replace (dt) {
this.node.x += this.ballAccel.y * dt * this.velocity;
this.node.y += this.ballAccel.x * dt * this.velocity;
},
The place this.ballAccel is a cc.v2, and this.velocity is only a single integer. The ball node strikes, however just isn’t taking devicemotion enter. I’ve tried to only dothis.node.x += this.ballAccel.y;
, nevertheless the problem persists.
Have you ever checked the instance I listing within the under.