Namespace: device

me. device

A singleton object representing the device capabilities and specific events
Source:
device.js, line 8

Members

<static, readonly> accelerationX :Number

contains the g-force acceleration along the x-axis.
Type:
  • Number
Source:
device.js, line 395

<static, readonly> accelerationY :Number

contains the g-force acceleration along the y-axis.
Type:
  • Number
Source:
device.js, line 405

<static, readonly> accelerationZ :Number

contains the g-force acceleration along the z-axis.
Type:
  • Number
Source:
device.js, line 415

<static, readonly> alpha :Number

Device orientation Alpha property. Gives angle based on the rotation of the phone around its z axis. The z-axis is perpendicular to the phone, facing out from the center of the screen.
Type:
  • Number
Source:
device.js, line 445

<static, readonly> android :Boolean

equals to true if the device is an Android platform.
Type:
  • Boolean
Source:
device.js, line 308

<static, readonly> android2 :Boolean

equals to true if the device is an Android 2.x platform.
Type:
  • Boolean
Source:
device.js, line 317

<static, readonly> beta :Number

Device orientation Beta property. Gives angle on tilting a portrait held phone forward or backward
Type:
  • Number
Source:
device.js, line 435

<static, readonly> BlackBerry :Boolean

equals to true if the device is a BlackBerry platform.
Type:
  • Boolean
Source:
device.js, line 364

<static, readonly> chromeOS :Boolean

equals to true if the device is running on ChromeOS.
Type:
  • Boolean
Source:
device.js, line 346

<static, readonly> cocoon :Boolean

equals to true if the game is running under cocoon/cocoonJS.
Type:
  • Boolean
Source:
device.js, line 336
See:

<static, readonly> ejecta :Boolean

equals to true if the game is running under Ejecta.
Type:
  • Boolean
Source:
device.js, line 326
See:

<static, readonly> gamma :Number

Device orientation Gamma property. Gives angle on tilting a portrait held phone left or right
Type:
  • Number
Source:
device.js, line 425

<static, readonly> hasAccelerometer :Boolean

Browser accelerometer capabilities
Type:
  • Boolean
Source:
device.js, line 217

<static, readonly> hasDeviceOrientation :Boolean

Browser device orientation
Type:
  • Boolean
Source:
device.js, line 226

<static, readonly> hasFullscreenSupport :Boolean

Browser full screen support
Type:
  • Boolean
Source:
device.js, line 235

<static, readonly> hasPointerLockSupport :Boolean

Browser pointerlock api support
Type:
  • Boolean
Source:
device.js, line 244

<static, readonly> iOS :Boolean

equals to true if the device is an iOS platform.
Type:
  • Boolean
Source:
device.js, line 299

<static, readonly> isFullscreen :Boolean

Returns true if the browser/device is in full screen mode.
Type:
  • Boolean
Source:
device.js, line 770

<static, readonly> isMobile :Boolean

equals to true if a mobile device
(Android | iPhone | iPad | iPod | BlackBerry | Windows Phone | Kindle)
Type:
  • Boolean
Source:
device.js, line 289

<static, readonly> Kindle :Boolean

equals to true if the device is a Kindle platform.
Type:
  • Boolean
Source:
device.js, line 373

<static, readonly> language :String

a string representing the preferred language of the user, usually the language of the browser UI. (will default to "en" if the information is not available)
Type:
  • String
Source:
device.js, line 456
See:

<static, readonly> localStorage :Boolean

Browser Local Storage capabilities
(this flag will be set to false if cookies are blocked)
Type:
  • Boolean
Source:
device.js, line 207

<static, readonly> maxTouchPoints :Number

Return the maximum number of touch contacts of current device.
Type:
  • Number
Source:
device.js, line 262

<static, readonly> nativeBase64 :Boolean

Browser Base64 decoding capability
Type:
  • Boolean
Source:
device.js, line 253

<static, readonly> orientation :Number

The device current orientation status.
0 : default orientation
90 : 90 degrees clockwise from default
-90 : 90 degrees anti-clockwise from default
180 : 180 degrees from default
Type:
  • Number
Source:
device.js, line 382

<static, readonly> sound :Boolean

Returns true if the browser/device has audio capabilities.
Type:
  • Boolean
Source:
device.js, line 794

<static, readonly> touch :Boolean

Touch capabilities
Type:
  • Boolean
Source:
device.js, line 271

<static, readonly> ua :String

the `ua` read-only property returns the user agent string for the current browser.
Type:
  • String
Source:
device.js, line 198

<static, readonly> wheel :Boolean

W3C standard wheel events
Type:
  • Boolean
Source:
device.js, line 280

<static, readonly> wp :Boolean

equals to true if the device is a Windows Phone platform.
Type:
  • Boolean
Source:
device.js, line 355

Methods

<static> enableSwipe(enable)

enable/disable swipe on WebView.
Parameters:
Name Type Argument Default Description
enable boolean <optional>
true enable or disable swipe.
Source:
device.js, line 468

<static> exitFullscreen()

Exit fullscreen mode. Requires fullscreen support from the browser/device.
Source:
device.js, line 517

<static> getPixelRatio()

return the device pixel ratio
Source:
device.js, line 529

<static> getStorage(type)

return the device storage
Parameters:
Name Type Argument Default Description
type String <optional>
"local"
Source:
device.js, line 551
Returns:
me.save object

<static> requestFullscreen(element)

Triggers a fullscreen request. Requires fullscreen support from the browser/device.
Parameters:
Name Type Argument Default Description
element Object <optional>
default canvas object the element to be set in full-screen mode.
Source:
device.js, line 487
Example
// add a keyboard shortcut to toggle Fullscreen mode on/off
me.input.bindKey(me.input.KEY.F, "toggleFullscreen");
me.event.subscribe(me.event.KEYDOWN, function (action, keyCode, edge) {
   // toggle fullscreen on/off
   if (action === "toggleFullscreen") {
      if (!me.device.isFullscreen) {
         me.device.requestFullscreen();
      } else {
         me.device.exitFullscreen();
      }
   }
});

<static> turnOffPointerLock()

Exits pointer lock. Works on supported devices & browsers
Source:
device.js, line 642

<static> turnOnPointerLock()

Enters pointer lock, requesting it from the user first. Works on supported devices & browsers Must be called in a click event or an event that requires user interaction. If you need to run handle events for errors or change of the pointer lock, see below.
Source:
device.js, line 599
Example
document.addEventListener("pointerlockchange", pointerlockchange, false);
document.addEventListener("mozpointerlockchange", pointerlockchange, false);
document.addEventListener("webkitpointerlockchange", pointerlockchange, false);

document.addEventListener("pointerlockerror", pointerlockerror, false);
document.addEventListener("mozpointerlockerror", pointerlockerror, false);
document.addEventListener("webkitpointerlockerror", pointerlockerror, false);

<static> unwatchAccelerometer()

unwatch Accelerometor event
Source:
device.js, line 688

<static> unwatchDeviceOrientation()

unwatch Device orientation event
Source:
device.js, line 726

<static> vibrate(pattern)

the vibrate method pulses the vibration hardware on the device,
If the device doesn't support vibration, this method has no effect.
If a vibration pattern is already in progress when this method is called, the previous pattern is halted and the new one begins instead.
Parameters:
Name Type Description
pattern Number | Array.<Number> pattern of vibration and pause intervals
Source:
device.js, line 740
Example
// vibrate for 1000 ms
navigator.vibrate(1000);
// or alternatively
navigator.vibrate([1000]);
// vibrate for 50 ms, be still for 100 ms, and then vibrate for 150 ms:
navigator.vibrate([50, 100, 150]);
// cancel any existing vibrations
navigator.vibrate(0);

<static> watchAccelerometer() → {Boolean}

watch Accelerator event
Source:
device.js, line 654
Returns:
false if not supported by the device
Type
Boolean

<static> watchDeviceOrientation() → {Boolean}

watch the device orientation event
Source:
device.js, line 710
Returns:
false if not supported by the device
Type
Boolean
Copyright © 2011 - 2017, Olivier Biot, Jason Oster, Aaron McLeod
Documentation generated by JSDoc 3.4.0 on 2017-02-28T11:37:40+08:00 using the DocStrap template modified by codename-.