How to use global

Comprehensive global code examples:

How to use global.settings:

3
4
5
6
7
8
9
10
11
12
var global = require('global');
var sounds = require('sounds');
var scene = require('scene');
var utils = require('utils');

var settings = global.settings;

function preload() {
  global.phaserGame.stage.scaleMode = Phaser.StageScaleMode.SHOW_ALL;
  global.phaserGame.stage.scale.setScreenSize(true);

How to use global.require:

116
117
118
119
120
121
122
123
124
125
 *
 * @api private
 */

Instrument.prototype.replace = function(){
  var mods = global.require.modules;
  var mod = this.mod;
  var src = mod.instrumented;
  mods[mod.key] = Function('exports', 'require', 'module', src);
};

How to use global.localStorage:

95
96
97
98
99
100
101
102
103
 * td.trackEvent('willbetracked') // will send td_ip and td_client_id; td_global_id will also be sent if set.
 */
exports.setSignedMode = function setSignedMode () {
  if (this.client.storeConsentByLocalStorage) {
    if (!misc.isLocalStorageAccessible()) return this
    global.localStorage.setItem(SIGNEDMODECOOKIE, 'true')
  } else {
    setCookie(this.client.storage, SIGNEDMODECOOKIE, 'true')
  }

How to use global.phaserGame:

7
8
9
10
11
12
13
14
15
16

var settings = global.settings;

function preload() {
  global.phaserGame.stage.scaleMode = Phaser.StageScaleMode.SHOW_ALL;
  global.phaserGame.stage.scale.setScreenSize(true);

  sounds.preload();
  scene.preload();
}