Phaser.Device

Detects device support capabilities and is responsible for device initialization - see whenReady.

This class represents a singleton object that can be accessed directly as game.device (or, as a fallback, Phaser.Device when a gameinstance is not available) without the need to instantiate it.

Unless otherwise noted the device capabilities are only guaranteed after initialization. Initialization occurs automatically and is guaranteed complete before Phaser.Game begins its "boot" phase. Feature detection can be modified in the onInitialized signal.

When checking features using the exposed properties only the truth-iness of the value should be relied upon unless the documentation states otherwise: properties may return false, '', null, or even undefined when indicating the lack of a feature.

Uses elements from System.js by MrDoob and Modernizr

<internal> new Device()

It is not possible to instantiate the Device class manually.

Internal: - This member is internal (protected) and may be modified or removed in the future.

Source - utils/Device.js, line 30

Members

<static, nullable> onInitialized:Phaser.Signal

This signal is dispatched after device initialization occurs but before any of the ready callbacks (see`whenReady <Phaser.Device.html#.whenReady>`__) have been invoked.

Local "patching" for a particular device can/should be done in this event.

Note: This signal is removed after the device has been readied; if a handler has not been added before new Phaser.Game(..) it is probably too late.

Source - utils/Device.js, line 561

android:boolean

Is running on android?

Source - utils/Device.js, line 118

arora:boolean

Set to true if running in Arora.

Source - utils/Device.js, line 274

audioData:boolean

Are Audio tags available?

Source - utils/Device.js, line 384

cancelFullscreen:string

If the browser supports the Full Screen API this holds the call you need to use to cancel it.

Source - utils/Device.js, line 535

canHandleAlpha:boolean

If the browser isn't capable of handling tinting with alpha this will be false.

Source - utils/Device.js, line 169

canUseMultiply:boolean

Whether or not the Canvas Blend Modes are supported, consequently the ability to tint using the multiply method.

Expect false in Internet Explorer <= 11. Source - utils/Device.js, line 179

canvas:boolean

Is canvas available?

Source - utils/Device.js, line 156

canvasBitBltShift:boolean

True if canvas supports a 'copy' bitblt onto itself when the source and destination regions overlap.

Source - utils/Device.js, line 162

chrome:boolean

Set to true if running in Chrome.

Source - utils/Device.js, line 280

chromeOS:boolean

Is running on chromeOS?

Source - utils/Device.js, line 124

chromeVersion:number

If running in Chrome this will contain the major version number.

Source - utils/Device.js, line 286

cocoonJS:boolean

Is the game running under CocoonJS?

Source - utils/Device.js, line 70

cocoonJSApp:boolean

Is this game running with CocoonJS.App?

Source - utils/Device.js, line 76

cordova:boolean

Is the game running under Apache Cordova?

Source - utils/Device.js, line 82

crosswalk:boolean

Is the game running under the Intel Crosswalk XDK?

Source - utils/Device.js, line 112

css3D:boolean

Is css3D available?

Source - utils/Device.js, line 215

desktop:boolean

Is running on a desktop?

Source - utils/Device.js, line 52

<internal>deviceReadyAt:integer

The time the device became ready.

Internal: - This member is internal (protected) and may be modified or removed in the future.

Source - utils/Device.js, line 37

dolby:boolean

Can this device play EC-3 Dolby Digital Plus files?

Source - utils/Device.js, line 433

edge:boolean

Set to true if running in Microsoft Edge browser.

Source - utils/Device.js, line 334

ejecta:boolean

Is the game running under Ejecta?

Source - utils/Device.js, line 106

electron:boolean

Is the game running under GitHub Electron?

Source - utils/Device.js, line 100

epiphany:boolean

Set to true if running in Epiphany.

Source - utils/Device.js, line 292

file:boolean

Is file available?

Source - utils/Device.js, line 191

fileSystem:boolean

Is fileSystem available?

Source - utils/Device.js, line 197

firefox:boolean

Set to true if running in Firefox.

Source - utils/Device.js, line 298

firefoxVersion:number

If running in Firefox this will contain the major version number.

Source - utils/Device.js, line 304

fullscreen:boolean

Does the browser support the Full Screen API?

Source - utils/Device.js, line 523

fullscreenKeyboard:boolean

Does the browser support access to the Keyboard during Full Screen mode?

Source - utils/Device.js, line 541

getUserMedia:boolean

Does the device support the getUserMedia API?

Default Value: - true

Source - utils/Device.js, line 239

h264Video:boolean

Can this device play h264 mp4 video files?

Source - utils/Device.js, line 447

hlsVideo:boolean

Can this device play hls video files?

Source - utils/Device.js, line 471

ie:boolean

Set to true if running in Internet Explorer.

Source - utils/Device.js, line 310

ieVersion:number

If running in Internet Explorer this will contain the major version number. Beyond IE10 you should use Device.trident and Device.tridentVersion.

Source - utils/Device.js, line 316

<internal>initialized:boolean

The time as which initialization has completed.

Internal: - This member is internal (protected) and may be modified or removed in the future.

Source - utils/Device.js, line 44

iOS:boolean

Is running on iOS?

Source - utils/Device.js, line 58

iOSVersion:number

If running in iOS this will contain the major version number.

Source - utils/Device.js, line 64

iPad:boolean

Is running on iPad?

Source - utils/Device.js, line 491

iPhone:boolean

Is running on iPhone?

Source - utils/Device.js, line 479

iPhone4:boolean

Is running on iPhone4?

Source - utils/Device.js, line 485

linux:boolean

Is running on linux?

Source - utils/Device.js, line 130

LITTLE_ENDIAN:boolean

Same value as littleEndian.

Source - utils/Device.js, line 511

littleEndian:boolean

Is the device big or little endian? (only detected if the browsersupports TypedArrays)

Source - utils/Device.js, line 505

localStorage:boolean

Is localStorage available?

Source - utils/Device.js, line 203

m4a:boolean

Can this device play m4a files? True if this device can play m4a files.

Source - utils/Device.js, line 421

macOS:boolean

Is running on macOS?

Source - utils/Device.js, line 136

midori:boolean

Set to true if running in Midori.

Source - utils/Device.js, line 346

mobileSafari:boolean

Set to true if running in Mobile Safari.

Source - utils/Device.js, line 340

mp3:boolean

Can this device play mp3 files?

Source - utils/Device.js, line 408

mp4Video:boolean

Can this device play h264 mp4 video files?

Source - utils/Device.js, line 453

mspointer:boolean

Is mspointer available?

Source - utils/Device.js, line 259

node:boolean

Is the game running under Node.js?

Source - utils/Device.js, line 88

nodeWebkit:boolean

Is the game running under Node-Webkit?

Source - utils/Device.js, line 94

ogg:boolean

Can this device play ogg files?

Source - utils/Device.js, line 396

oggVideo:boolean

Can this device play ogg video files?

Source - utils/Device.js, line 441

opera:boolean

Set to true if running in Opera.

Source - utils/Device.js, line 352

opus:boolean

Can this device play opus files?

Source - utils/Device.js, line 402

pixelRatio:number

PixelRatio of the host device?

Source - utils/Device.js, line 499

pointerLock:boolean

Is Pointer Lock available?

Source - utils/Device.js, line 221

quirksMode:boolean

Is the browser running in strict mode (false) or quirks mode? (true)

Source - utils/Device.js, line 245

requestFullscreen:string

If the browser supports the Full Screen API this holds the call you need to use to activate it.

Source - utils/Device.js, line 529

safari:boolean

Set to true if running in Safari.

Source - utils/Device.js, line 358

safariVersion:number

If running in Safari this will contain the major version number.

Source - utils/Device.js, line 364

silk:boolean

Set to true if running in the Silk browser (as used on the AmazonKindle)

Source - utils/Device.js, line 376

support32bit:boolean

Does the device context support 32bit pixel manipulation using array buffer views?

Source - utils/Device.js, line 517

touch:boolean

Is touch available?

Source - utils/Device.js, line 253

trident:boolean

Set to true if running a Trident version of Internet Explorer (IE11+)

Source - utils/Device.js, line 322

tridentVersion:number

If running in Internet Explorer 11 this will contain the major version number. See http://msdn.microsoft.com/en-us/library/ie/ms537503(v=vs.85).aspx

Source - utils/Device.js, line 328

typedArray:boolean

Does the browser support TypedArrays?

Source - utils/Device.js, line 227

vibration:boolean

Does the device support the Vibration API?

Source - utils/Device.js, line 233

vp9Video:boolean

Can this device play vp9 video files?

Source - utils/Device.js, line 465

wav:boolean

Can this device play wav files?

Source - utils/Device.js, line 414

webApp:boolean

Set to true if running as a WebApp, i.e. within a WebView

Source - utils/Device.js, line 370

webAudio:boolean

Is the WebAudio API available?

Source - utils/Device.js, line 390

webGL:boolean

Is webGL available?

Source - utils/Device.js, line 185

webm:boolean

Can this device play webm files?

Source - utils/Device.js, line 427

webmVideo:boolean

Can this device play webm video files?

Source - utils/Device.js, line 459

<internal>wheelEvent

Name

Type

Argument

Description

wheelType

string

<nullable>

The newest type of Wheel/Scroll event supported: 'wheel', 'mousewheel', 'DOMMouseScroll'

Internal: - This member is internal (protected) and may be modified or removed in the future.

Source - utils/Device.js, line 266

windows:boolean

Is running on windows?

Source - utils/Device.js, line 142

windowsPhone:boolean

Is running on a Windows Phone?

Source - utils/Device.js, line 148

worker:boolean

Is worker available?

Source - utils/Device.js, line 209

Methods

<static> whenReady(handler, context, nonPrimer)

Add a device-ready handler and ensure the device ready sequence is started.

Phaser.Device will not activate or initialize until at least one whenReady handler is added, which is normally done automatically be calling new Phaser.Game(..).

The handler is invoked when the device is considered "ready", which may be immediately if the device is already "ready". See deviceReadyAt.

Name

Type

Argument

Default

Description

handler

function

Callback to invoke when the device is ready. It is invoked with the given context the Phaser.Device object is supplied as the first argument.

context

object

<optional>

Context in which to invoke the handler

nonPrimer

boolean

<optional>

false

If true the device ready check will not be started.

Source - utils/Device.js, line 577

canPlayAudio(type)→ {boolean}

Check whether the host environment can play audio.

Name

Type

Description

type

string

One of 'mp3, 'ogg', 'm4a', 'wav', 'webm' or 'opus'.

boolean-

True if the given file type is supported by the browser, otherwise false.

Source - utils/Device.js, line 1313

canPlayVideo(type)→ {boolean}

Check whether the host environment can play video files.

Name

Type

Description

type

string

One of 'mp4, 'ogg', 'webm' or 'mpeg'.

boolean-

True if the given file type is supported by the browser, otherwise false.

Source - utils/Device.js, line 1356

isAndroidStockBrowser()

Detect if the host is a an Android Stock browser. This is available before the device "ready" event.

Authors might want to scale down on effects and switch to the CANVAS rendering method on those devices.

Source - utils/Device.js, line 1422

isConsoleOpen()

Check whether the console is open. Note that this only works in Firefox with Firebug and earlier versions of Chrome. It used to work in Chrome, but then they removed the ability: http://src.chromium.org/viewvc/blink?view=revision&revision=151136

Source - utils/Device.js, line 1387