In the use of Daniel touchsnow development plug-in cocoseditor game development encountered some problems, and then try to solve, recently want to try the coocs2d-html5 can use gravity sensing, found that is OK, however, this can only be tested on a mobile real machine, but not on a computer simulator,
You must first set the Accelerometer in 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 rewrite onAccelerometer (); Method MainLayer. prototype. onAccelerometer = function (event) {cc. log ("event: x. "+ event. x + "; y. "+ event. y + "; z. "+ event. z );}
In this way, the accelerator can be used,
X, y, and z coordinates can be output after real machine testing. OK