[XDK/JS] Making it so the screen will start on

Due to unique nature of control in my game (tilting the phone) I need a way to make sure that phone’s screen will stay on and unlocked or game will be unplayable. Any idea how to do that?

Take a look here: software.intel.com/en-us/node/493027

As it will work only when using intel XDK, you may want to test for the intel object existence:

if (typeof intel !== "undefined") { //Call intel.xdk.* }

Actually, defined objects resolve to true, so if (intel) is enough. But thanks. Will take a look.

Yes, but if intel is not defined (when you preview for example), you’ll get a syntax error, unless you use typeof :slight_smile:

Undefined == false in boolean operations: mapbender.org/JavaScript_pit … #undefined

Cheers! :slight_smile:

No, really, when a symbol is not defined, that is to say the variable wasn’t even written anywhere, then you’ll have an error. :slight_smile:

Just test it in a js file or open your developer console and type:

if (intel) console.log("Hello");

will break (ReferenceError: intel is not defined on my Firefox), whereas :

if (typeof intel === "undefined") console.log("Hello");

will print hello. :slight_smile:
You’re free not to use typeof here, but it will surely break whenver you execute the game in an environment where intel variable is not defined (that is too say, where the symbol is not even declared).

Ah, okay. Though due to innovative controls I can’t test it without device anyway.