COOCS2D-HTML5 calls the device's accelerometer when using cocoseditor to use gravity sensing

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.