In the use of Daniel Touchsnow developed plug-in cocoseditor development game encountered some problems, and then try to solve, recently want to try COOCS2D-HTML5 can use gravity sensor, found that is possible, but this can only be tested on the mobile real machine, The simulator on the computer is not working,
You first need to set the accelerometer within the ONDIDLOADFROMCCB () method:
This.rootNode.onAccelerometer = function (event) { this.controller.onAccelerometer (event);}; Cc.log ("Sys.os:" + Sys.os); if (Sys.os = = "Android" | | Sys.os = = "ios") { this.rootNode.setAccelerometerEnabled (true);} Then it is to rewrite onaccelerometer (); Method MainLayer.prototype.onAccelerometer = function (event) { cc.log ("event:x." + Event.x + "; Y. "+ Event.y +"; Z. "+ event.z);}
This means that you can use an accelerator,
You can output x, y, Z coordinates after a real machine test, OK