2018-02-12 16:01:20 +00:00
/ * *
* @ author Richard Davey < rich @ photonstorm . com >
* @ copyright 2018 Photon Storm Ltd .
* @ license { @ link https : //github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
* /
2017-06-30 14:47:51 +00:00
var Class = require ( '../utils/Class' ) ;
2016-11-24 15:40:05 +00:00
var CONST = require ( '../const' ) ;
2018-08-22 16:01:21 +00:00
var Device = require ( '../device' ) ;
2018-05-10 16:15:25 +00:00
var GetFastValue = require ( '../utils/object/GetFastValue' ) ;
2017-04-26 15:03:14 +00:00
var GetValue = require ( '../utils/object/GetValue' ) ;
2018-05-10 16:15:25 +00:00
var IsPlainObject = require ( '../utils/object/IsPlainObject' ) ;
2017-09-13 16:09:16 +00:00
var MATH = require ( '../math/const' ) ;
2018-11-13 15:05:35 +00:00
var NumberArray = require ( '../utils/array/NumberArray' ) ;
2018-10-24 13:08:49 +00:00
var RND = require ( '../math/random-data-generator/RandomDataGenerator' ) ;
2017-06-30 14:47:51 +00:00
var NOOP = require ( '../utils/NOOP' ) ;
2018-05-11 13:06:13 +00:00
var DefaultPlugins = require ( '../plugins/DefaultPlugins' ) ;
2017-10-11 16:05:59 +00:00
var ValueToColor = require ( '../display/color/ValueToColor' ) ;
2016-11-24 15:40:05 +00:00
2017-10-04 18:59:08 +00:00
/ * *
* This callback type is completely empty , a no - operation .
*
* @ callback NOOP
* /
2018-03-19 21:37:47 +00:00
/ * *
* @ callback BootCallback
*
2018-09-27 22:37:54 +00:00
* @ param { Phaser . Game } game - The game .
2018-03-19 21:37:47 +00:00
* /
2018-08-12 10:19:48 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* Config object containing various sound settings .
*
2018-11-21 00:30:30 +00:00
* @ typedef { object } AudioConfig
2018-10-22 12:47:46 +00:00
*
2018-11-21 00:30:30 +00:00
* @ property { boolean } [ disableWebAudio = false ] - Use HTML5 Audio instead of Web Audio .
* @ property { AudioContext } [ context ] - An existing Web Audio context .
* @ property { boolean } [ noAudio = false ] - Disable all audio output .
*
* @ see Phaser . Sound . SoundManagerCreator
2018-10-22 12:47:46 +00:00
* /
2018-10-24 13:08:49 +00:00
/ * *
2018-08-12 10:19:48 +00:00
* @ typedef { object } InputConfig
*
2018-09-27 22:37:54 +00:00
* @ property { ( boolean | KeyboardInputConfig ) } [ keyboard = true ] - Keyboard input configuration . ` true ` uses the default configuration and ` false ` disables keyboard input .
* @ property { ( boolean | MouseInputConfig ) } [ mouse = true ] - Mouse input configuration . ` true ` uses the default configuration and ` false ` disables mouse input .
* @ property { ( boolean | TouchInputConfig ) } [ touch = true ] - Touch input configuration . ` true ` uses the default configuration and ` false ` disables touch input .
* @ property { ( boolean | GamepadInputConfig ) } [ gamepad = false ] - Gamepad input configuration . ` true ` enables gamepad input .
* @ property { integer } [ activePointers = 1 ] - The maximum number of touch pointers . See { @ link Phaser . Input . InputManager # pointers } .
2018-11-19 15:30:21 +00:00
* @ property { number } [ smoothFactor = 0 ] - The smoothing factor to apply during Pointer movement . See { @ link Phaser . Input . Pointer # smoothFactor } .
2018-08-12 10:19:48 +00:00
* /
/ * *
* @ typedef { object } MouseInputConfig
*
2018-09-27 22:37:54 +00:00
* @ property { * } [ target = null ] - Where the Mouse Manager listens for mouse input events . The default is the game canvas .
2018-11-12 22:22:12 +00:00
* @ property { boolean } [ capture = true ] - Whether mouse input events have ` preventDefault ` called on them .
2018-08-12 10:19:48 +00:00
* /
/ * *
* @ typedef { object } KeyboardInputConfig
*
2018-09-27 22:37:54 +00:00
* @ property { * } [ target = window ] - Where the Keyboard Manager listens for keyboard input events .
2018-11-13 15:05:35 +00:00
* @ property { ( boolean | integer [ ] ) } [ capture ] - ` preventDefault ` will be called on every non - modified key which has a key code in this array . By default , it 's set to all the space key, cursors and all alphanumeric keys. Or, set to ' false ' to disable .
2018-08-12 10:19:48 +00:00
* /
/ * *
* @ typedef { object } TouchInputConfig
*
2018-09-27 22:37:54 +00:00
* @ property { * } [ target = null ] - Where the Touch Manager listens for touch input events . The default is the game canvas .
* @ property { boolean } [ capture = true ] - Whether touch input events have preventDefault ( ) called on them .
2018-08-12 10:19:48 +00:00
* /
/ * *
* @ typedef { object } GamepadInputConfig
*
2018-09-27 22:37:54 +00:00
* @ property { * } [ target = window ] - Where the Gamepad Manager listens for gamepad input events .
2018-08-12 10:19:48 +00:00
* /
/ * *
* @ typedef { object } BannerConfig
*
2018-09-27 22:37:54 +00:00
* @ property { boolean } [ hidePhaser = false ] - Omit Phaser ' s name and version from the banner .
* @ property { string } [ text = '#ffffff' ] - The color of the banner text .
* @ property { string [ ] } [ background ] - The background colors of the banner .
2018-08-12 10:19:48 +00:00
* /
2017-10-04 22:48:16 +00:00
/ * *
* @ typedef { object } FPSConfig
2018-01-08 16:39:46 +00:00
*
2018-10-22 12:47:46 +00:00
* @ property { integer } [ min = 5 ] - The minimum acceptable rendering rate , in frames per second .
2018-09-27 22:37:54 +00:00
* @ property { integer } [ target = 60 ] - The optimum rendering rate , in frames per second .
* @ property { boolean } [ forceSetTimeOut = false ] - Use setTimeout instead of requestAnimationFrame to run the game loop .
* @ property { integer } [ deltaHistory = 10 ] - Calculate the average frame delta from this many consecutive frame intervals .
2018-10-22 12:47:46 +00:00
* @ property { integer } [ panicMax = 120 ] - The amount of frames the time step counts before we trust the delta values again .
2017-10-04 22:48:16 +00:00
* /
2018-08-12 10:19:48 +00:00
/ * *
* @ typedef { object } RenderConfig
*
2018-09-27 22:37:54 +00:00
* @ property { boolean } [ antialias = true ] - When set to ` true ` , WebGL uses linear interpolation to draw scaled or rotated textures , giving a smooth appearance . When set to ` false ` , WebGL uses nearest - neighbor interpolation , giving a crisper appearance . ` false ` also disables antialiasing of the game canvas itself , if the browser supports it , when the game canvas is scaled .
* @ property { boolean } [ pixelArt = false ] - Sets ` antialias ` and ` roundPixels ` to true . This is the best setting for pixel - art games .
2018-08-31 17:19:25 +00:00
* @ property { boolean } [ autoResize = true ] - Automatically resize the Game Canvas if you resize the renderer .
2018-09-27 22:37:54 +00:00
* @ property { boolean } [ roundPixels = false ] - Draw texture - based Game Objects at only whole - integer positions . Game Objects without textures , like Graphics , ignore this property .
* @ property { boolean } [ transparent = false ] - Whether the game canvas will be transparent .
* @ property { boolean } [ clearBeforeRender = true ] - Whether the game canvas will be cleared between each rendering frame .
* @ property { boolean } [ premultipliedAlpha = true ] - In WebGL mode , the drawing buffer contains colors with pre - multiplied alpha .
* @ property { boolean } [ failIfMajorPerformanceCaveat = false ] - Let the browser abort creating a WebGL context if it judges performance would be unacceptable .
* @ property { string } [ powerPreference = 'default' ] - "high-performance" , "low-power" or "default" . A hint to the browser on how much device power the game might use .
2018-08-12 10:19:48 +00:00
* @ property { integer } [ batchSize = 2000 ] - The default WebGL batch size .
2018-10-02 10:09:58 +00:00
* @ property { integer } [ maxLights = 10 ] - The maximum number of lights allowed to be visible within range of a single Camera in the LightManager .
2018-08-12 10:19:48 +00:00
* /
2018-08-07 15:25:45 +00:00
/ * *
* @ typedef { object } ScaleConfig
*
* @ property { ( integer | string ) } [ width = 1024 ] - The base width of your game .
* @ property { ( integer | string ) } [ height = 768 ] - The base height of your game .
* @ property { integer } [ zoom = 1 ] - The zoom value of the game canvas .
* @ property { number } [ resolution = 1 ] - The rendering resolution of the canvas .
2018-09-27 22:37:54 +00:00
* @ property { ( HTMLElement | string ) } [ parent ] - The DOM element that will contain the game canvas , or its ` id ` . If null ( the default ) or if the named element doesn ' t exist , the game canvas is inserted directly into the document body .
* @ property { integer } [ mode = 0 ] - The scale mode to apply to the canvas . SHOW _ALL , EXACT _FIT , USER _SCALE , or RESIZE .
2018-08-07 15:25:45 +00:00
* @ property { integer } [ minWidth ] - The minimum width the canvas can be scaled down to .
* @ property { integer } [ minHeight ] - The minimum height the canvas can be scaled down to .
* @ property { integer } [ maxWidth ] - The maximum width the canvas can be scaled up to .
* @ property { integer } [ maxHeight ] - The maximum height the canvas can be scaled up to .
* /
2018-08-12 10:19:48 +00:00
/ * *
* @ typedef { object } CallbacksConfig
*
2018-09-27 22:37:54 +00:00
* @ property { BootCallback } [ preBoot = NOOP ] - A function to run at the start of the boot sequence .
* @ property { BootCallback } [ postBoot = NOOP ] - A function to run at the end of the boot sequence . At this point , all the game systems have started and plugins have been loaded .
2018-08-12 10:19:48 +00:00
* /
2017-10-04 22:48:16 +00:00
/ * *
2018-01-25 00:48:48 +00:00
* @ typedef { object } LoaderConfig
2017-10-04 22:48:16 +00:00
*
2018-10-22 12:47:46 +00:00
* @ property { string } [ baseURL ] - A URL used to resolve paths given to the loader . Example : 'http://labs.phaser.io/assets/' .
* @ property { string } [ path ] - A URL path used to resolve relative paths given to the loader . Example : 'images/sprites/' .
2018-09-27 22:37:54 +00:00
* @ property { integer } [ maxParallelDownloads = 32 ] - The maximum number of resources the loader will start loading at once .
* @ property { ( string | undefined ) } [ crossOrigin = undefined ] - 'anonymous' , 'use-credentials' , or ` undefined ` . If you ' re not making cross - origin requests , leave this as ` undefined ` . See { @ link https : //developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes}.
* @ property { string } [ responseType ] - The response type of the XHR request , e . g . ` blob ` , ` text ` , etc .
* @ property { boolean } [ async = true ] - Should the XHR request use async or not ?
2018-10-22 12:47:46 +00:00
* @ property { string } [ user ] - Optional username for all XHR requests .
* @ property { string } [ password ] - Optional password for all XHR requests .
2018-09-27 22:37:54 +00:00
* @ property { integer } [ timeout = 0 ] - Optional XHR timeout value , in ms .
2018-01-25 00:48:48 +00:00
* /
2018-07-18 16:22:52 +00:00
/ * *
* @ typedef { object } DOMContainerConfig
*
* @ property { boolean } [ createContainer = false ] - Create a div element in which DOM Elements will be contained . You must also provide a parent .
* @ property { boolean } [ behindCanvas = false ] - Place the DOM Container behind the Phaser Canvas . The default is to place it over the Canvas .
* /
2018-08-12 10:19:48 +00:00
/ * *
* @ typedef { object } ImagesConfig
*
2018-09-27 22:37:54 +00:00
* @ property { string } [ default ] - URL to use for the 'default' texture .
* @ property { string } [ missing ] - URL to use for the 'missing' texture .
2018-08-12 10:19:48 +00:00
* /
2018-09-27 22:37:54 +00:00
/ * *
* @ typedef { object } PhysicsConfig
*
* @ property { string } [ default ] - The default physics system . It will be started for each scene . Phaser provides 'arcade' , 'impact' , and 'matter' .
* @ property { ArcadeWorldConfig } [ arcade ] - Arcade Physics configuration .
* @ property { Phaser . Physics . Impact . WorldConfig } [ impact ] - Impact Physics configuration .
* @ property { object } [ matter ] - Matter Physics configuration .
* /
2018-08-12 10:19:48 +00:00
/ * *
2018-08-07 19:38:28 +00:00
* @ typedef { object } PluginObjectItem
2018-08-12 10:19:48 +00:00
*
2018-09-27 22:37:54 +00:00
* @ property { string } [ key ] - A key to identify the plugin in the Plugin Manager .
* @ property { * } [ plugin ] - The plugin itself . Usually a class / constructor .
* @ property { boolean } [ start ] - Whether the plugin should be started automatically .
* @ property { string } [ systemKey ] - For a scene plugin , add the plugin to the scene ' s systems object under this key ( ` this.sys.KEY ` , from the scene ) .
* @ property { string } [ sceneKey ] - For a scene plugin , add the plugin to the scene object under this key ( ` this.KEY ` , from the scene ) .
* @ property { * } [ data ] - Arbitrary data passed to the plugin ' s init ( ) method .
*
* @ example
* // Global plugin
* { key : 'BankPlugin' , plugin : BankPluginV3 , start : true , data : { gold : 5000 } }
* @ example
* // Scene plugin
* { key : 'WireFramePlugin' , plugin : WireFramePlugin , systemKey : 'wireFramePlugin' , sceneKey : 'wireframe' }
2018-08-07 19:38:28 +00:00
* /
2018-08-12 10:19:48 +00:00
/ * *
2018-08-07 19:38:28 +00:00
* @ typedef { object } PluginObject
2018-08-12 10:19:48 +00:00
*
2018-09-27 22:37:54 +00:00
* @ property { ? PluginObjectItem [ ] } [ global ] - Global plugins to install .
* @ property { ? PluginObjectItem [ ] } [ scene ] - Scene plugins to install .
* @ property { string [ ] } [ default ] - The default set of scene plugins ( names ) .
* @ property { string [ ] } [ defaultMerge ] - Plugins to * add * to the default set of scene plugins .
2018-08-07 19:38:28 +00:00
* /
2018-01-25 00:48:48 +00:00
/ * *
* @ typedef { object } GameConfig
2018-01-08 16:39:46 +00:00
*
2018-09-27 22:37:54 +00:00
* @ property { ( integer | string ) } [ width = 1024 ] - The width of the game , in game pixels .
* @ property { ( integer | string ) } [ height = 768 ] - The height of the game , in game pixels .
* @ property { number } [ zoom = 1 ] - Simple scale applied to the game canvas . 2 is double size , 0.5 is half size , etc .
* @ property { number } [ resolution = 1 ] - The size of each game pixel , in canvas pixels . Values larger than 1 are "high" resolution .
* @ property { number } [ type = CONST . AUTO ] - Which renderer to use . Phaser . AUTO , Phaser . CANVAS , Phaser . HEADLESS , or Phaser . WEBGL . AUTO picks WEBGL if available , otherwise CANVAS .
* @ property { ( HTMLElement | string ) } [ parent = null ] - The DOM element that will contain the game canvas , or its ` id ` . If null ( the default ) or if the named element doesn ' t exist , the game canvas is inserted directly into the document body .
2018-05-10 11:25:33 +00:00
* @ property { HTMLCanvasElement } [ canvas = null ] - Provide your own Canvas element for Phaser to use instead of creating one .
2018-09-27 22:37:54 +00:00
* @ property { string } [ canvasStyle = null ] - CSS styles to apply to the game canvas instead of Phaser ' s default styles .
2018-05-10 11:25:33 +00:00
* @ property { CanvasRenderingContext2D } [ context ] - Provide your own Canvas Context for Phaser to use , instead of creating one .
2018-09-27 22:37:54 +00:00
* @ property { object } [ scene = null ] - A scene or scenes to add to the game . If several are given , the first is started ; the remainder are started only if they have { active : true } .
* @ property { string [ ] } [ seed ] - Seed for the random number generator .
* @ property { string } [ title = '' ] - The title of the game . Shown in the browser console .
* @ property { string } [ url = 'http://phaser.io' ] - The URL of the game . Shown in the browser console .
* @ property { string } [ version = '' ] - The version of the game . Shown in the browser console .
* @ property { boolean } [ autoFocus = true ] - Automatically call window . focus ( ) when the game boots . Usually necessary to capture input events if the game is in a separate frame .
* @ property { ( boolean | InputConfig ) } [ input ] - Input configuration , or ` false ` to disable all game input .
* @ property { boolean } [ disableContextMenu = false ] - Disable the browser 's default ' contextmenu ' event ( usually triggered by a right - button mouse click ) .
* @ property { ( boolean | BannerConfig ) } [ banner = false ] - Configuration for the banner printed in the browser console when the game starts .
2018-07-18 16:22:52 +00:00
* @ property { DOMContainerConfig } [ dom ] - The DOM Container configuration object .
2018-09-27 22:37:54 +00:00
* @ property { FPSConfig } [ fps ] - Game loop configuration .
* @ property { RenderConfig } [ render ] - Game renderer configuration .
* @ property { ( string | number ) } [ backgroundColor = 0x000000 ] - The background color of the game canvas . The default is black .
* @ property { CallbacksConfig } [ callbacks ] - Optional callbacks to run before or after game boot .
* @ property { LoaderConfig } [ loader ] - Loader configuration .
* @ property { ImagesConfig } [ images ] - Images configuration .
* @ property { object } [ physics ] - Physics configuration .
* @ property { PluginObject | PluginObjectItem [ ] } [ plugins ] - Plugins to install .
2017-10-04 22:48:16 +00:00
* /
2018-02-07 15:27:21 +00:00
/ * *
* @ classdesc
2018-09-27 22:37:54 +00:00
* The active game configuration settings , parsed from a { @ link GameConfig } object .
2018-02-07 15:27:21 +00:00
*
* @ class Config
2018-10-10 09:49:13 +00:00
* @ memberof Phaser . Boot
2018-02-07 15:27:21 +00:00
* @ constructor
* @ since 3.0 . 0
*
2018-03-19 16:55:21 +00:00
* @ param { GameConfig } [ GameConfig ] - The configuration object for your Phaser Game instance .
2018-09-27 22:37:54 +00:00
*
* @ see Phaser . Game # config
2018-02-07 15:27:21 +00:00
* /
2017-06-30 14:47:51 +00:00
var Config = new Class ( {
initialize :
function Config ( config )
{
if ( config === undefined ) { config = { } ; }
2016-11-24 15:40:05 +00:00
2017-06-30 14:47:51 +00:00
var defaultBannerColor = [
'#ff0000' ,
'#ffff00' ,
'#00ff00' ,
'#00ffff' ,
'#000000'
] ;
2016-11-24 15:40:05 +00:00
2017-06-30 14:47:51 +00:00
var defaultBannerTextColor = '#ffffff' ;
2016-11-24 01:35:02 +00:00
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { ( integer | string ) } Phaser . Boot . Config # width - The width of the underlying canvas , in pixels .
2018-05-08 08:17:13 +00:00
* /
2017-06-30 14:47:51 +00:00
this . width = GetValue ( config , 'width' , 1024 ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { ( integer | string ) } Phaser . Boot . Config # height - The height of the underlying canvas , in pixels .
2018-05-08 08:17:13 +00:00
* /
2017-06-30 14:47:51 +00:00
this . height = GetValue ( config , 'height' , 768 ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { number } Phaser . Boot . Config # zoom - The zoom factor , as used by the Scale Manager .
2018-05-08 08:17:13 +00:00
* /
2017-06-30 14:47:51 +00:00
this . zoom = GetValue ( config , 'zoom' , 1 ) ;
2016-11-24 15:40:05 +00:00
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { number } Phaser . Boot . Config # resolution - The canvas device pixel resolution .
2018-05-08 08:17:13 +00:00
* /
2017-06-30 14:47:51 +00:00
this . resolution = GetValue ( config , 'resolution' , 1 ) ;
2016-11-24 15:40:05 +00:00
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { ? * } Phaser . Boot . Config # parent - A parent DOM element into which the canvas created by the renderer will be injected .
2018-05-08 08:17:13 +00:00
* /
2018-08-07 15:25:45 +00:00
this . parent = GetValue ( config , 'parent' , null ) ;
2016-11-24 15:40:05 +00:00
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { integer } Phaser . Boot . Config # scaleMode - The scale mode as used by the Scale Manager . The default is zero , which is no scaling .
2018-05-08 08:17:13 +00:00
* /
2018-08-07 15:25:45 +00:00
this . scaleMode = GetValue ( config , 'scaleMode' , 0 ) ;
2018-10-11 16:01:17 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { boolean } Phaser . Boot . Config # expandParent - Is the Scale Manager allowed to adjust the size of the parent container ?
2018-10-11 16:01:17 +00:00
* /
this . expandParent = GetValue ( config , 'expandParent' , false ) ;
/ * *
2018-10-22 12:47:46 +00:00
* @ const { integer } Phaser . Boot . Config # minWidth - The minimum width , in pixels , the canvas will scale down to . A value of zero means no minimum .
2018-10-11 16:01:17 +00:00
* /
this . minWidth = GetValue ( config , 'minWidth' , 0 ) ;
/ * *
2018-10-22 12:47:46 +00:00
* @ const { integer } Phaser . Boot . Config # maxWidth - The maximum width , in pixels , the canvas will scale up to . A value of zero means no maximum .
2018-10-11 16:01:17 +00:00
* /
this . maxWidth = GetValue ( config , 'maxWidth' , 0 ) ;
/ * *
2018-10-22 12:47:46 +00:00
* @ const { integer } Phaser . Boot . Config # minHeight - The minimum height , in pixels , the canvas will scale down to . A value of zero means no minimum .
2018-10-11 16:01:17 +00:00
* /
this . minHeight = GetValue ( config , 'minHeight' , 0 ) ;
/ * *
2018-10-22 12:47:46 +00:00
* @ const { integer } Phaser . Boot . Config # maxHeight - The maximum height , in pixels , the canvas will scale up to . A value of zero means no maximum .
2018-10-11 16:01:17 +00:00
* /
this . maxHeight = GetValue ( config , 'maxHeight' , 0 ) ;
2018-08-07 15:25:45 +00:00
// Scale Manager - Anything set in here over-rides anything set above
var scaleConfig = GetValue ( config , 'scale' , null ) ;
if ( scaleConfig )
{
this . width = GetValue ( scaleConfig , 'width' , this . width ) ;
this . height = GetValue ( scaleConfig , 'height' , this . height ) ;
this . zoom = GetValue ( scaleConfig , 'zoom' , this . zoom ) ;
this . resolution = GetValue ( scaleConfig , 'resolution' , this . resolution ) ;
this . parent = GetValue ( scaleConfig , 'parent' , this . parent ) ;
this . scaleMode = GetValue ( scaleConfig , 'mode' , this . scaleMode ) ;
2018-10-11 16:01:17 +00:00
this . expandParent = GetValue ( scaleConfig , 'mode' , this . expandParent ) ;
this . minWidth = GetValue ( scaleConfig , 'min.width' , this . minWidth ) ;
this . maxWidth = GetValue ( scaleConfig , 'max.width' , this . maxWidth ) ;
this . minHeight = GetValue ( scaleConfig , 'min.height' , this . minHeight ) ;
this . maxHeight = GetValue ( scaleConfig , 'max.height' , this . maxHeight ) ;
2018-08-07 15:25:45 +00:00
}
/ * *
2018-09-24 22:20:43 +00:00
* @ const { number } Phaser . Boot . Config # renderType - Force Phaser to use a specific renderer . Can be ` CONST.CANVAS ` , ` CONST.WEBGL ` , ` CONST.HEADLESS ` or ` CONST.AUTO ` ( default )
2018-08-07 15:25:45 +00:00
* /
this . renderType = GetValue ( config , 'type' , CONST . AUTO ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-05-10 11:25:33 +00:00
* @ const { ? HTMLCanvasElement } Phaser . Boot . Config # canvas - Force Phaser to use your own Canvas element instead of creating one .
2018-05-08 08:17:13 +00:00
* /
2017-06-30 14:47:51 +00:00
this . canvas = GetValue ( config , 'canvas' , null ) ;
2018-05-08 08:17:13 +00:00
2018-05-10 11:25:33 +00:00
/ * *
* @ const { ? ( CanvasRenderingContext2D | WebGLRenderingContext ) } Phaser . Boot . Config # context - Force Phaser to use your own Canvas context instead of creating one .
* /
2018-05-10 11:42:08 +00:00
this . context = GetValue ( config , 'context' , null ) ;
2018-05-10 11:25:33 +00:00
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { ? string } Phaser . Boot . Config # canvasStyle - Optional CSS attributes to be set on the canvas object created by the renderer .
2018-05-08 08:17:13 +00:00
* /
2017-06-30 14:47:51 +00:00
this . canvasStyle = GetValue ( config , 'canvasStyle' , null ) ;
2016-11-24 15:40:05 +00:00
2018-11-16 10:46:30 +00:00
/ * *
* @ const { boolean } Phaser . Boot . Config # customEnvironment - Is Phaser running under a custom ( non - native web ) environment ? If so , set this to ` true ` to skip internal Feature detection . If ` true ` the ` renderType ` cannot be left as ` AUTO ` .
* /
this . customEnvironment = GetValue ( config , 'customEnvironment' , false ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { ? object } Phaser . Boot . Config # sceneConfig - The default Scene configuration object .
2018-05-08 08:17:13 +00:00
* /
2017-07-14 13:30:20 +00:00
this . sceneConfig = GetValue ( config , 'scene' , null ) ;
2016-11-24 15:40:05 +00:00
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { string [ ] } Phaser . Boot . Config # seed - A seed which the Random Data Generator will use . If not given , a dynamic seed based on the time is used .
2018-05-08 08:17:13 +00:00
* /
2017-06-30 14:47:51 +00:00
this . seed = GetValue ( config , 'seed' , [ ( Date . now ( ) * Math . random ( ) ) . toString ( ) ] ) ;
2016-11-24 15:40:05 +00:00
2018-10-24 13:08:49 +00:00
MATH . RND = new RND ( ) ;
2017-06-30 14:47:51 +00:00
MATH . RND . init ( this . seed ) ;
2017-01-25 12:01:52 +00:00
2018-05-08 08:17:13 +00:00
/ * *
2018-09-27 14:29:32 +00:00
* @ const { string } Phaser . Boot . Config # gameTitle - The title of the game .
2018-05-08 08:17:13 +00:00
* /
2017-06-30 14:47:51 +00:00
this . gameTitle = GetValue ( config , 'title' , '' ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-09-27 14:29:32 +00:00
* @ const { string } Phaser . Boot . Config # gameURL - The URL of the game .
2018-05-08 08:17:13 +00:00
* /
2018-01-28 04:10:44 +00:00
this . gameURL = GetValue ( config , 'url' , 'https://phaser.io' ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-09-27 14:29:32 +00:00
* @ const { string } Phaser . Boot . Config # gameVersion - The version of the game .
2018-05-08 08:17:13 +00:00
* /
2017-06-30 14:47:51 +00:00
this . gameVersion = GetValue ( config , 'version' , '' ) ;
2016-11-24 15:40:05 +00:00
2018-05-18 16:37:45 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { boolean } Phaser . Boot . Config # autoFocus - If ` true ` the window will automatically be given focus immediately and on any future mousedown event .
2018-05-18 16:37:45 +00:00
* /
this . autoFocus = GetValue ( config , 'autoFocus' , true ) ;
2018-07-18 16:22:52 +00:00
// DOM Element Container
/ * *
2018-10-22 12:47:46 +00:00
* @ const { ? boolean } Phaser . Boot . Config # domCreateContainer - EXPERIMENTAL : Do not currently use .
2018-07-18 16:22:52 +00:00
* /
this . domCreateContainer = GetValue ( config , 'dom.createContainer' , false ) ;
/ * *
2018-10-22 12:47:46 +00:00
* @ const { ? boolean } Phaser . Boot . Config # domBehindCanvas - EXPERIMENTAL : Do not currently use .
2018-07-18 16:22:52 +00:00
* /
this . domBehindCanvas = GetValue ( config , 'dom.behindCanvas' , false ) ;
2017-06-30 14:47:51 +00:00
// Input
2018-05-10 11:25:33 +00:00
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { boolean } Phaser . Boot . Config # inputKeyboard - Enable the Keyboard Plugin . This can be disabled in games that don ' t need keyboard input .
2018-05-08 08:17:13 +00:00
* /
2017-06-30 14:47:51 +00:00
this . inputKeyboard = GetValue ( config , 'input.keyboard' , true ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { * } Phaser . Boot . Config # inputKeyboardEventTarget - The DOM Target to listen for keyboard events on . Defaults to ` window ` if not specified .
2018-05-08 08:17:13 +00:00
* /
2017-06-30 14:47:51 +00:00
this . inputKeyboardEventTarget = GetValue ( config , 'input.keyboard.target' , window ) ;
2017-02-21 01:04:11 +00:00
2018-11-12 22:22:12 +00:00
/ * *
2018-11-13 15:05:35 +00:00
* @ const { ( boolean | integer [ ] ) } Phaser . Boot . Config # inputKeyboardCapture - ` preventDefault ` will be called on every non - modified key which has a key code in this array . By default , it 's set to all alphanumeric keys. Or, set to ' false ' to disable .
2018-11-12 22:22:12 +00:00
* /
2018-11-13 15:05:35 +00:00
var defaultCaptures = [ 32 , 38 , 39 , 40 , 42 ] ;
defaultCaptures = defaultCaptures . concat ( NumberArray ( 48 , 57 ) ) ;
defaultCaptures = defaultCaptures . concat ( NumberArray ( 65 , 90 ) ) ;
var keyboardCapture = GetValue ( config , 'input.keyboard.capture' , defaultCaptures ) ;
if ( ! Array . isArray ( keyboardCapture ) )
{
keyboardCapture = [ ] ;
}
this . inputKeyboardCapture = keyboardCapture ;
2018-11-12 22:22:12 +00:00
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { ( boolean | object ) } Phaser . Boot . Config # inputMouse - Enable the Mouse Plugin . This can be disabled in games that don ' t need mouse input .
2018-05-08 08:17:13 +00:00
* /
2017-06-30 14:47:51 +00:00
this . inputMouse = GetValue ( config , 'input.mouse' , true ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { ? * } Phaser . Boot . Config # inputMouseEventTarget - The DOM Target to listen for mouse events on . Defaults to the game canvas if not specified .
2018-05-08 08:17:13 +00:00
* /
2017-06-30 14:47:51 +00:00
this . inputMouseEventTarget = GetValue ( config , 'input.mouse.target' , null ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { boolean } Phaser . Boot . Config # inputMouseCapture - Should mouse events be captured ? I . e . have prevent default called on them .
2018-05-08 08:17:13 +00:00
* /
2017-12-27 23:52:46 +00:00
this . inputMouseCapture = GetValue ( config , 'input.mouse.capture' , true ) ;
2017-06-12 23:38:48 +00:00
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { boolean } Phaser . Boot . Config # inputTouch - Enable the Touch Plugin . This can be disabled in games that don ' t need touch input .
2018-05-08 08:17:13 +00:00
* /
2018-08-22 16:01:21 +00:00
this . inputTouch = GetValue ( config , 'input.touch' , Device . input . touch ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { ? * } Phaser . Boot . Config # inputTouchEventTarget - The DOM Target to listen for touch events on . Defaults to the game canvas if not specified .
2018-05-08 08:17:13 +00:00
* /
2017-07-28 02:28:10 +00:00
this . inputTouchEventTarget = GetValue ( config , 'input.touch.target' , null ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { boolean } Phaser . Boot . Config # inputTouchCapture - Should touch events be captured ? I . e . have prevent default called on them .
2018-05-08 08:17:13 +00:00
* /
2017-12-27 23:52:46 +00:00
this . inputTouchCapture = GetValue ( config , 'input.touch.capture' , true ) ;
2017-07-28 02:28:10 +00:00
2018-05-29 23:33:01 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { integer } Phaser . Boot . Config # inputActivePointers - The number of Pointer objects created by default . In a mouse - only , or non - multi touch game , you can leave this as 1.
2018-05-29 23:33:01 +00:00
* /
this . inputActivePointers = GetValue ( config , 'input.activePointers' , 1 ) ;
2018-11-19 15:30:21 +00:00
/ * *
* @ const { integer } Phaser . Boot . Config # inputSmoothFactor - The smoothing factor to apply during Pointer movement . See { @ link Phaser . Input . Pointer # smoothFactor } .
* /
this . inputSmoothFactor = GetValue ( config , 'input.smoothFactor' , 0 ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { boolean } Phaser . Boot . Config # inputGamepad - Enable the Gamepad Plugin . This can be disabled in games that don ' t need gamepad input .
2018-05-08 08:17:13 +00:00
* /
2017-09-13 13:18:34 +00:00
this . inputGamepad = GetValue ( config , 'input.gamepad' , false ) ;
2017-09-09 02:17:13 +00:00
2018-06-06 22:03:27 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { * } Phaser . Boot . Config # inputGamepadEventTarget - The DOM Target to listen for gamepad events on . Defaults to ` window ` if not specified .
2018-06-06 22:03:27 +00:00
* /
this . inputGamepadEventTarget = GetValue ( config , 'input.gamepad.target' , window ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { boolean } Phaser . Boot . Config # disableContextMenu - Set to ` true ` to disable the right - click context menu .
2018-05-08 08:17:13 +00:00
* /
2017-07-25 11:33:37 +00:00
this . disableContextMenu = GetValue ( config , 'disableContextMenu' , false ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-11-21 00:30:30 +00:00
* @ const { AudioConfig } Phaser . Boot . Config # audio - The Audio Configuration object .
2018-05-08 08:17:13 +00:00
* /
2018-01-08 16:39:46 +00:00
this . audio = GetValue ( config , 'audio' ) ;
2017-06-30 14:47:51 +00:00
// If you do: { banner: false } it won't display any banner at all
2018-05-10 11:25:33 +00:00
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { boolean } Phaser . Boot . Config # hideBanner - Don ' t write the banner line to the console . log .
2018-05-08 08:17:13 +00:00
* /
2017-06-30 14:47:51 +00:00
this . hideBanner = ( GetValue ( config , 'banner' , null ) === false ) ;
2016-11-24 15:40:05 +00:00
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { boolean } Phaser . Boot . Config # hidePhaser - Omit Phaser ' s name and version from the banner .
2018-05-08 08:17:13 +00:00
* /
2017-06-30 14:47:51 +00:00
this . hidePhaser = GetValue ( config , 'banner.hidePhaser' , false ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { string } Phaser . Boot . Config # bannerTextColor - The color of the banner text .
2018-05-08 08:17:13 +00:00
* /
2017-06-30 14:47:51 +00:00
this . bannerTextColor = GetValue ( config , 'banner.text' , defaultBannerTextColor ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { string [ ] } Phaser . Boot . Config # bannerBackgroundColor - The background colors of the banner .
2018-05-08 08:17:13 +00:00
* /
2017-06-30 14:47:51 +00:00
this . bannerBackgroundColor = GetValue ( config , 'banner.background' , defaultBannerColor ) ;
2017-10-04 22:48:16 +00:00
if ( this . gameTitle === '' && this . hidePhaser )
{
this . hideBanner = true ;
}
2018-01-08 16:39:46 +00:00
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { ? FPSConfig } Phaser . Boot . Config # fps - The Frame Rate Configuration object , as parsed by the Timestep class .
2018-05-08 08:17:13 +00:00
* /
2017-06-30 14:47:51 +00:00
this . fps = GetValue ( config , 'fps' , null ) ;
2017-02-07 18:41:53 +00:00
2018-03-15 21:15:12 +00:00
// Renderer Settings
2018-03-16 13:22:52 +00:00
// These can either be in a `render` object within the Config, or specified on their own
var renderConfig = GetValue ( config , 'render' , config ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-08-31 17:19:25 +00:00
* @ const { boolean } Phaser . Boot . Config # autoResize - Automatically resize the Game Canvas if you resize the renderer .
2018-05-08 08:17:13 +00:00
* /
2018-08-31 17:19:25 +00:00
this . autoResize = GetValue ( renderConfig , 'autoResize' , true ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { boolean } Phaser . Boot . Config # antialias - When set to ` true ` , WebGL uses linear interpolation to draw scaled or rotated textures , giving a smooth appearance . When set to ` false ` , WebGL uses nearest - neighbor interpolation , giving a crisper appearance . ` false ` also disables antialiasing of the game canvas itself , if the browser supports it , when the game canvas is scaled .
2018-05-08 08:17:13 +00:00
* /
2018-06-27 14:27:16 +00:00
this . antialias = GetValue ( renderConfig , 'antialias' , true ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { boolean } Phaser . Boot . Config # roundPixels - Draw texture - based Game Objects at only whole - integer positions . Game Objects without textures , like Graphics , ignore this property .
2018-05-08 08:17:13 +00:00
* /
2018-06-27 14:27:16 +00:00
this . roundPixels = GetValue ( renderConfig , 'roundPixels' , false ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-09-27 14:29:32 +00:00
* @ const { boolean } Phaser . Boot . Config # pixelArt - Prevent pixel art from becoming blurred when scaled . It will remain crisp ( tells the WebGL renderer to automatically create textures using a linear filter mode ) .
2018-05-08 08:17:13 +00:00
* /
2018-06-27 14:27:16 +00:00
this . pixelArt = GetValue ( renderConfig , 'pixelArt' , false ) ;
if ( this . pixelArt )
{
this . antialias = false ;
this . roundPixels = true ;
}
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { boolean } Phaser . Boot . Config # transparent - Whether the game canvas will have a transparent background .
2018-05-08 08:17:13 +00:00
* /
2018-03-16 13:22:52 +00:00
this . transparent = GetValue ( renderConfig , 'transparent' , false ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { boolean } Phaser . Boot . Config # clearBeforeRender - Whether the game canvas will be cleared between each rendering frame . You can disable this if you have a full - screen background image or game object .
2018-05-08 08:17:13 +00:00
* /
2018-03-16 13:22:52 +00:00
this . clearBeforeRender = GetValue ( renderConfig , 'clearBeforeRender' , true ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { boolean } Phaser . Boot . Config # premultipliedAlpha - In WebGL mode , sets the drawing buffer to contain colors with pre - multiplied alpha .
2018-05-08 08:17:13 +00:00
* /
2018-03-16 13:22:52 +00:00
this . premultipliedAlpha = GetValue ( renderConfig , 'premultipliedAlpha' , true ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { boolean } Phaser . Boot . Config # failIfMajorPerformanceCaveat - Let the browser abort creating a WebGL context if it judges performance would be unacceptable .
2018-05-08 08:17:13 +00:00
* /
2018-03-16 13:22:52 +00:00
this . failIfMajorPerformanceCaveat = GetValue ( renderConfig , 'failIfMajorPerformanceCaveat' , false ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { string } Phaser . Boot . Config # powerPreference - "high-performance" , "low-power" or "default" . A hint to the browser on how much device power the game might use .
2018-05-08 08:17:13 +00:00
* /
2018-03-16 13:22:52 +00:00
this . powerPreference = GetValue ( renderConfig , 'powerPreference' , 'default' ) ;
2018-02-28 21:15:18 +00:00
2018-07-02 11:33:46 +00:00
/ * *
* @ const { integer } Phaser . Boot . Config # batchSize - The default WebGL Batch size .
* /
this . batchSize = GetValue ( renderConfig , 'batchSize' , 2000 ) ;
2018-10-02 10:09:58 +00:00
/ * *
* @ const { integer } Phaser . Boot . Config # maxLights - The maximum number of lights allowed to be visible within range of a single Camera in the LightManager .
* /
this . maxLights = GetValue ( renderConfig , 'maxLights' , 10 ) ;
2018-07-02 11:33:46 +00:00
2018-02-28 21:15:18 +00:00
var bgc = GetValue ( config , 'backgroundColor' , 0 ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-11-13 15:05:35 +00:00
* @ const { Phaser . Display . Color } Phaser . Boot . Config # backgroundColor - The background color of the game canvas . The default is black . This value is ignored if ` transparent ` is set to ` true ` .
2018-05-08 08:17:13 +00:00
* /
2018-02-28 21:15:18 +00:00
this . backgroundColor = ValueToColor ( bgc ) ;
if ( bgc === 0 && this . transparent )
{
this . backgroundColor . alpha = 0 ;
}
2016-11-25 02:08:33 +00:00
2018-05-08 08:17:13 +00:00
/ * *
2018-10-19 11:32:43 +00:00
* @ const { BootCallback } Phaser . Boot . Config # preBoot - Called before Phaser boots . Useful for initializing anything not related to Phaser that Phaser may require while booting .
2018-05-08 08:17:13 +00:00
* /
2017-06-30 14:47:51 +00:00
this . preBoot = GetValue ( config , 'callbacks.preBoot' , NOOP ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { BootCallback } Phaser . Boot . Config # postBoot - A function to run at the end of the boot sequence . At this point , all the game systems have started and plugins have been loaded .
2018-05-08 08:17:13 +00:00
* /
2017-06-30 14:47:51 +00:00
this . postBoot = GetValue ( config , 'callbacks.postBoot' , NOOP ) ;
2017-02-07 12:43:20 +00:00
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { PhysicsConfig } Phaser . Boot . Config # physics - The Physics Configuration object .
2018-05-08 08:17:13 +00:00
* /
2017-08-18 00:42:14 +00:00
this . physics = GetValue ( config , 'physics' , { } ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { ( boolean | string ) } Phaser . Boot . Config # defaultPhysicsSystem - The default physics system . It will be started for each scene . Either 'arcade' , 'impact' or 'matter' .
2018-05-08 08:17:13 +00:00
* /
2017-08-18 00:42:14 +00:00
this . defaultPhysicsSystem = GetValue ( this . physics , 'default' , false ) ;
2017-08-15 22:34:39 +00:00
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { string } Phaser . Boot . Config # loaderBaseURL - A URL used to resolve paths given to the loader . Example : 'http://labs.phaser.io/assets/' .
2018-05-08 08:17:13 +00:00
* /
2018-01-19 16:56:41 +00:00
this . loaderBaseURL = GetValue ( config , 'loader.baseURL' , '' ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { string } Phaser . Boot . Config # loaderPath - A URL path used to resolve relative paths given to the loader . Example : 'images/sprites/' .
2018-05-08 08:17:13 +00:00
* /
2018-01-19 16:56:41 +00:00
this . loaderPath = GetValue ( config , 'loader.path' , '' ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-09-27 14:29:32 +00:00
* @ const { integer } Phaser . Boot . Config # loaderMaxParallelDownloads - Maximum parallel downloads allowed for resources ( Default to 32 ) .
2018-05-08 08:17:13 +00:00
* /
2018-05-02 16:23:51 +00:00
this . loaderMaxParallelDownloads = GetValue ( config , 'loader.maxParallelDownloads' , 32 ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { ( string | undefined ) } Phaser . Boot . Config # loaderCrossOrigin - 'anonymous' , 'use-credentials' , or ` undefined ` . If you ' re not making cross - origin requests , leave this as ` undefined ` . See { @ link https : //developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes}.
2018-05-08 08:17:13 +00:00
* /
2018-01-19 16:56:41 +00:00
this . loaderCrossOrigin = GetValue ( config , 'loader.crossOrigin' , undefined ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { string } Phaser . Boot . Config # loaderResponseType - The response type of the XHR request , e . g . ` blob ` , ` text ` , etc .
2018-05-08 08:17:13 +00:00
* /
2018-01-19 16:56:41 +00:00
this . loaderResponseType = GetValue ( config , 'loader.responseType' , '' ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { boolean } Phaser . Boot . Config # loaderAsync - Should the XHR request use async or not ?
2018-05-08 08:17:13 +00:00
* /
2018-01-19 16:56:41 +00:00
this . loaderAsync = GetValue ( config , 'loader.async' , true ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { string } Phaser . Boot . Config # loaderUser - Optional username for all XHR requests .
2018-05-08 08:17:13 +00:00
* /
2018-01-19 16:56:41 +00:00
this . loaderUser = GetValue ( config , 'loader.user' , '' ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { string } Phaser . Boot . Config # loaderPassword - Optional password for all XHR requests .
2018-05-08 08:17:13 +00:00
* /
2018-01-19 16:56:41 +00:00
this . loaderPassword = GetValue ( config , 'loader.password' , '' ) ;
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { integer } Phaser . Boot . Config # loaderTimeout - Optional XHR timeout value , in ms .
2018-05-08 08:17:13 +00:00
* /
2018-01-19 16:56:41 +00:00
this . loaderTimeout = GetValue ( config , 'loader.timeout' , 0 ) ;
2018-05-10 16:15:25 +00:00
/ *
* Allows ` plugins ` property to either be an array , in which case it just replaces
2018-05-11 00:50:37 +00:00
* the default plugins like previously , or a config object .
2018-05-10 16:15:25 +00:00
*
* plugins : {
2018-05-11 17:55:44 +00:00
* global : [
2018-07-19 00:21:17 +00:00
* { key : 'TestPlugin' , plugin : TestPlugin , start : true , data : { msg : 'The plugin is alive' } } ,
2018-05-11 17:55:44 +00:00
* ] ,
* scene : [
* { key : 'WireFramePlugin' , plugin : WireFramePlugin , systemKey : 'wireFramePlugin' , sceneKey : 'wireframe' }
2018-05-10 16:15:25 +00:00
* ] ,
* default : [ ] , OR
2018-09-27 22:37:54 +00:00
* defaultMerge : [
2018-05-11 00:50:37 +00:00
* 'ModPlayer'
2018-09-27 22:37:54 +00:00
* ]
2018-05-10 16:15:25 +00:00
* }
* /
2018-05-11 00:50:37 +00:00
2018-05-11 15:01:11 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { any } Phaser . Boot . Config # installGlobalPlugins - An array of global plugins to be installed .
2018-05-11 15:01:11 +00:00
* /
this . installGlobalPlugins = [ ] ;
/ * *
2018-10-22 12:47:46 +00:00
* @ const { any } Phaser . Boot . Config # installScenePlugins - An array of Scene level plugins to be installed .
2018-05-11 15:01:11 +00:00
* /
this . installScenePlugins = [ ] ;
2018-05-11 00:50:37 +00:00
var plugins = GetValue ( config , 'plugins' , null ) ;
2018-05-11 13:06:13 +00:00
var defaultPlugins = DefaultPlugins . DefaultScene ;
2018-05-11 00:50:37 +00:00
2018-05-10 16:15:25 +00:00
if ( plugins )
{
// Old 3.7 array format?
if ( Array . isArray ( plugins ) )
{
this . defaultPlugins = plugins ;
}
else if ( IsPlainObject ( plugins ) )
{
2018-05-11 15:01:11 +00:00
this . installGlobalPlugins = GetFastValue ( plugins , 'global' , [ ] ) ;
this . installScenePlugins = GetFastValue ( plugins , 'scene' , [ ] ) ;
2018-05-10 16:15:25 +00:00
if ( Array . isArray ( plugins . default ) )
{
2018-05-11 00:50:37 +00:00
defaultPlugins = plugins . default ;
2018-05-10 16:15:25 +00:00
}
else if ( Array . isArray ( plugins . defaultMerge ) )
{
2018-05-11 00:50:37 +00:00
defaultPlugins = defaultPlugins . concat ( plugins . defaultMerge ) ;
2018-05-10 16:15:25 +00:00
}
}
}
2018-01-18 05:16:02 +00:00
2018-05-11 00:50:37 +00:00
/ * *
* @ const { any } Phaser . Boot . Config # defaultPlugins - The plugins installed into every Scene ( in addition to CoreScene and Global ) .
* /
this . defaultPlugins = defaultPlugins ;
2017-06-30 14:47:51 +00:00
// Default / Missing Images
var pngPrefix = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAg' ;
2017-03-28 22:56:00 +00:00
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { string } Phaser . Boot . Config # defaultImage - A base64 encoded PNG that will be used as the default blank texture .
2018-05-08 08:17:13 +00:00
* /
2017-06-30 14:47:51 +00:00
this . defaultImage = GetValue ( config , 'images.default' , pngPrefix + 'AQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg==' ) ;
2018-08-12 10:19:48 +00:00
2018-05-08 08:17:13 +00:00
/ * *
2018-10-22 12:47:46 +00:00
* @ const { string } Phaser . Boot . Config # missingImage - A base64 encoded PNG that will be used as the default texture when a texture is assigned that is missing or not loaded .
2018-05-08 08:17:13 +00:00
* /
2017-06-30 14:47:51 +00:00
this . missingImage = GetValue ( config , 'images.missing' , pngPrefix + 'CAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==' ) ;
2018-08-02 14:58:36 +00:00
if ( window )
{
if ( window . FORCE _WEBGL )
{
this . renderType = CONST . WEBGL ;
}
else if ( window . FORCE _CANVAS )
{
this . renderType = CONST . CANVAS ;
}
}
2017-06-30 14:47:51 +00:00
}
2016-11-24 01:35:02 +00:00
2017-06-30 14:47:51 +00:00
} ) ;
2016-11-24 01:35:02 +00:00
module . exports = Config ;