This commit is contained in:
Greg 2018-02-09 16:28:41 -05:00
commit 8563c69879
62 changed files with 4091 additions and 411 deletions

View file

@ -8,8 +8,18 @@ var ParseXMLBitmapFont = require('../gameobjects/bitmaptext/ParseXMLBitmapFont')
var PluginManager = require('../plugins/PluginManager');
var XHRSettings = require('./XHRSettings');
// Phaser.Loader.LoaderPlugin
/**
* @classdesc
* [description]
*
* @class LoaderPlugin
* @extends Phaser.Loader.EventEmitter
* @memberOf Phaser.Loader
* @constructor
* @since 3.0.0
*
* @param {Phaser.Scene} scene - [description]
*/
var LoaderPlugin = new Class({
Extends: EventEmitter,
@ -20,8 +30,22 @@ var LoaderPlugin = new Class({
{
EventEmitter.call(this);
/**
* [description]
*
* @name Phaser.Loader.LoaderPlugin#scene
* @type {Phaser.Scene}
* @since 3.0.0
*/
this.scene = scene;
/**
* [description]
*
* @name Phaser.Loader.LoaderPlugin#systems
* @type {Phaser.Scenes.Systems}
* @since 3.0.0
*/
this.systems = scene.sys;
if (!scene.sys.settings.isBooted)
@ -29,6 +53,15 @@ var LoaderPlugin = new Class({
scene.sys.events.once('boot', this.boot, this);
}
/**
* [description]
*
* @name Phaser.Loader.LoaderPlugin#_multilist
* @type {object}
* @private
* @default {}
* @since 3.0.0
*/
this._multilist = {};
// Inject the available filetypes into the Loader
@ -37,16 +70,55 @@ var LoaderPlugin = new Class({
var gameConfig = this.systems.game.config;
var sceneConfig = this.systems.settings.loader;
/**
* [description]
*
* @name Phaser.Loader.LoaderPlugin#path
* @type {string}
* @default ''
* @since 3.0.0
*/
this.path = '';
/**
* [description]
*
* @name Phaser.Loader.LoaderPlugin#baseURL
* @type {string}
* @default ''
* @since 3.0.0
*/
this.baseURL = '';
this.setBaseURL(GetFastValue(sceneConfig, 'baseURL', gameConfig.loaderBaseURL));
this.setPath(GetFastValue(sceneConfig, 'path', gameConfig.loaderPath));
/**
* [description]
*
* @name Phaser.Loader.LoaderPlugin#enableParallel
* @type {boolean}
* @since 3.0.0
*/
this.enableParallel = GetFastValue(sceneConfig, 'enableParallel', gameConfig.loaderEnableParallel);
/**
* [description]
*
* @name Phaser.Loader.LoaderPlugin#maxParallelDownloads
* @type {integer}
* @since 3.0.0
*/
this.maxParallelDownloads = GetFastValue(sceneConfig, 'maxParallelDownloads', gameConfig.loaderMaxParallelDownloads);
// xhr specific global settings (can be overridden on a per-file basis)
/**
* xhr specific global settings (can be overridden on a per-file basis)
*
* @name Phaser.Loader.LoaderPlugin#xhr
* @type {Phaser.Loader.XHRSettings}
* @since 3.0.0
*/
this.xhr = XHRSettings(
GetFastValue(sceneConfig, 'responseType', gameConfig.loaderResponseType),
GetFastValue(sceneConfig, 'async', gameConfig.loaderAsync),
@ -55,20 +127,96 @@ var LoaderPlugin = new Class({
GetFastValue(sceneConfig, 'timeout', gameConfig.loaderTimeout)
);
/**
* [description]
*
* @name Phaser.Loader.LoaderPlugin#crossOrigin
* @type {string}
* @since 3.0.0
*/
this.crossOrigin = GetFastValue(sceneConfig, 'crossOrigin', gameConfig.loaderCrossOrigin);
/**
* [description]
*
* @name Phaser.Loader.LoaderPlugin#totalToLoad
* @type {number}
* @default 0
* @since 3.0.0
*/
this.totalToLoad = 0;
/**
* [description]
*
* @name Phaser.Loader.LoaderPlugin#progress
* @type {number}
* @default 0
* @since 3.0.0
*/
this.progress = 0;
/**
* [description]
*
* @name Phaser.Loader.LoaderPlugin#list
* @type {Phaser.Structs.Set}
* @since 3.0.0
*/
this.list = new CustomSet();
/**
* [description]
*
* @name Phaser.Loader.LoaderPlugin#inflight
* @type {Phaser.Structs.Set}
* @since 3.0.0
*/
this.inflight = new CustomSet();
/**
* [description]
*
* @name Phaser.Loader.LoaderPlugin#failed
* @type {Phaser.Structs.Set}
* @since 3.0.0
*/
this.failed = new CustomSet();
/**
* [description]
*
* @name Phaser.Loader.LoaderPlugin#queue
* @type {Phaser.Structs.Set}
* @since 3.0.0
*/
this.queue = new CustomSet();
/**
* [description]
*
* @name Phaser.Loader.LoaderPlugin#storage
* @type {Phaser.Structs.Set}
* @since 3.0.0
*/
this.storage = new CustomSet();
/**
* [description]
*
* @name Phaser.Loader.LoaderPlugin#state
* @type {integer}
* @since 3.0.0
*/
this.state = CONST.LOADER_IDLE;
},
/**
* [description]
*
* @method Phaser.Loader.LoaderPlugin#boot
* @since 3.0.0
*/
boot: function ()
{
var eventEmitter = this.systems.events;
@ -77,6 +225,16 @@ var LoaderPlugin = new Class({
eventEmitter.on('destroy', this.destroy, this);
},
/**
* [description]
*
* @method Phaser.Loader.LoaderPlugin#setBaseURL
* @since 3.0.0
*
* @param {string} url - [description]
*
* @return {Phaser.Loader.LoaderPlugin} This Loader object.
*/
setBaseURL: function (url)
{
if (url !== '' && url.substr(-1) !== '/')
@ -89,6 +247,16 @@ var LoaderPlugin = new Class({
return this;
},
/**
* [description]
*
* @method Phaser.Loader.LoaderPlugin#setPath
* @since 3.0.0
*
* @param {string} path - [description]
*
* @return {Phaser.Loader.LoaderPlugin} This Loader object.
*/
setPath: function (path)
{
if (path !== '' && path.substr(-1) !== '/')
@ -101,6 +269,16 @@ var LoaderPlugin = new Class({
return this;
},
/**
* [description]
*
* @method Phaser.Loader.LoaderPlugin#addFile
* @since 3.0.0
*
* @param {Phaser.Loader.File} file - [description]
*
* @return {Phaser.Loader.File} [description]
*/
addFile: function (file)
{
if (!this.isReady())
@ -115,22 +293,40 @@ var LoaderPlugin = new Class({
return file;
},
// Is the Loader actively loading (or processing loaded files)
/**
* Is the Loader actively loading (or processing loaded files)
*
* @method Phaser.Loader.LoaderPlugin#isLoading
* @since 3.0.0
*
* @return {boolean} [description]
*/
isLoading: function ()
{
return (this.state === CONST.LOADER_LOADING || this.state === CONST.LOADER_PROCESSING);
},
// Is the Loader ready to start a new load?
/**
* Is the Loader ready to start a new load?
*
* @method Phaser.Loader.LoaderPlugin#isReady
* @since 3.0.0
*
* @return {boolean} [description]
*/
isReady: function ()
{
return (this.state === CONST.LOADER_IDLE || this.state === CONST.LOADER_COMPLETE || this.state === CONST.LOADER_FAILED);
},
/**
* [description]
*
* @method Phaser.Loader.LoaderPlugin#start
* @since 3.0.0
*/
start: function ()
{
// console.log(this.scene.sys.settings.key, '- Loader start. Files to load:', this.list.size);
if (!this.isReady())
{
return;
@ -161,21 +357,27 @@ var LoaderPlugin = new Class({
}
},
/**
* [description]
*
* @method Phaser.Loader.LoaderPlugin#updateProgress
* @since 3.0.0
*/
updateProgress: function ()
{
this.progress = 1 - (this.list.size / this.totalToLoad);
// console.log(this.progress);
this.emit('progress', this.progress);
},
/**
* [description]
*
* @method Phaser.Loader.LoaderPlugin#processLoadQueue
* @since 3.0.0
*/
processLoadQueue: function ()
{
// console.log('======== LoaderPlugin processLoadQueue');
// console.log('List size', this.list.size);
// console.log(this.inflight.size, 'items still in flight. Can load another', (this.maxParallelDownloads - this.inflight.size));
this.list.each(function (file)
{
if (file.state === CONST.FILE_POPULATED || (file.state === CONST.FILE_PENDING && this.inflight.size < this.maxParallelDownloads))
@ -196,11 +398,16 @@ var LoaderPlugin = new Class({
}, this);
},
// private
/**
* [description]
*
* @method Phaser.Loader.LoaderPlugin#loadFile
* @since 3.0.0
*
* @param {Phaser.Loader.File} file - [description]
*/
loadFile: function (file)
{
// console.log('LOADING', file.key);
// If the file doesn't have its own crossOrigin set,
// we'll use the Loaders (which is undefined by default)
if (!file.crossOrigin)
@ -211,10 +418,17 @@ var LoaderPlugin = new Class({
file.load(this);
},
/**
* [description]
*
* @method Phaser.Loader.LoaderPlugin#nextFile
* @since 3.0.0
*
* @param {Phaser.Loader.File} previousFile - [description]
* @param {boolean} success - [description]
*/
nextFile: function (previousFile, success)
{
// console.log('LOADED:', previousFile.src, success);
// Move the file that just loaded from the inflight list to the queue or failed Set
if (success)
@ -234,20 +448,22 @@ var LoaderPlugin = new Class({
if (this.list.size > 0)
{
// console.log('nextFile - still something in the list');
this.processLoadQueue();
}
else if (this.inflight.size === 0)
{
// console.log('nextFile calling finishedLoading');
this.finishedLoading();
}
},
/**
* [description]
*
* @method Phaser.Loader.LoaderPlugin#finishedLoading
* @since 3.0.0
*/
finishedLoading: function ()
{
// console.log('---> LoaderPlugin.finishedLoading PROCESSING', this.queue.size, 'files');
if (this.state === CONST.LOADER_PROCESSING)
{
return;
@ -268,17 +484,21 @@ var LoaderPlugin = new Class({
{
this.queue.each(function (file)
{
// console.log('%c Calling process on ' + file.key, 'color: #000000; background: #ffff00;');
file.onProcess(this.processUpdate.bind(this));
}, this);
}
},
// Called automatically by the File when it has finished processing
/**
* Called automatically by the File when it has finished processing.
*
* @method Phaser.Loader.LoaderPlugin#processUpdate
* @since 3.0.0
*
* @param {Phaser.Loader.File} file - [description]
*/
processUpdate: function (file)
{
// console.log('-> processUpdate', file.key, file.state);
// This file has failed to load, so move it to the failed Set
if (file.state === CONST.FILE_ERRORED)
{
@ -317,6 +537,14 @@ var LoaderPlugin = new Class({
}
},
/**
* [description]
*
* @method Phaser.Loader.LoaderPlugin#removeFromQueue
* @since 3.0.0
*
* @param {Phaser.Loader.File} file - [description]
*/
removeFromQueue: function (file)
{
this.queue.delete(file);
@ -328,10 +556,14 @@ var LoaderPlugin = new Class({
}
},
/**
* [description]
*
* @method Phaser.Loader.LoaderPlugin#processComplete
* @since 3.0.0
*/
processComplete: function ()
{
// console.log(this.scene.sys.settings.key, '- Loader Complete. Loaded:', this.storage.size, 'Failed:', this.failed.size);
this.list.clear();
this.inflight.clear();
this.queue.clear();
@ -345,7 +577,12 @@ var LoaderPlugin = new Class({
this.removeAllListeners();
},
// The Loader has finished
/**
* The Loader has finished.
*
* @method Phaser.Loader.LoaderPlugin#processCallback
* @since 3.0.0
*/
processCallback: function ()
{
if (this.storage.size === 0)
@ -545,11 +782,34 @@ var LoaderPlugin = new Class({
this.storage.clear();
},
/**
* [description]
*
* @method Phaser.Loader.LoaderPlugin#saveJSON
* @since 3.0.0
*
* @param {[type]} data - [description]
* @param {[type]} filename - [description]
*
* @return {[type]} [description]
*/
saveJSON: function (data, filename)
{
return this.save(JSON.stringify(data), filename);
},
/**
* [description]
*
* @method Phaser.Loader.LoaderPlugin#save
* @since 3.0.0
*
* @param {[type]} data - [description]
* @param {[type]} filename - [description]
* @param {[type]} filetype - [description]
*
* @return {Phaser.Loader.LoaderPlugin} This Loader plugin.
*/
save: function (data, filename, filetype)
{
if (filename === undefined) { filename = 'file.json'; }
@ -569,6 +829,12 @@ var LoaderPlugin = new Class({
return this;
},
/**
* [description]
*
* @method Phaser.Loader.LoaderPlugin#reset
* @since 3.0.0
*/
reset: function ()
{
this.list.clear();
@ -586,6 +852,16 @@ var LoaderPlugin = new Class({
this.state = CONST.LOADER_IDLE;
},
/**
* [description]
*
* @method Phaser.Loader.LoaderPlugin#loadArray
* @since 3.0.0
*
* @param {array} files - [description]
*
* @return {boolean} [description]
*/
loadArray: function (files)
{
if (Array.isArray(files))
@ -599,6 +875,16 @@ var LoaderPlugin = new Class({
return (this.list.size > 0);
},
/**
* [description]
*
* @method Phaser.Loader.LoaderPlugin#file
* @since 3.0.0
*
* @param {object} file - [description]
*
* @return {Phaser.Loader.File} [description]
*/
file: function (file)
{
var entry;
@ -635,12 +921,24 @@ var LoaderPlugin = new Class({
return entry;
},
/**
* [description]
*
* @method Phaser.Loader.LoaderPlugin#shutdown
* @since 3.0.0
*/
shutdown: function ()
{
this.reset();
this.state = CONST.LOADER_SHUTDOWN;
},
/**
* [description]
*
* @method Phaser.Loader.LoaderPlugin#destroy
* @since 3.0.0
*/
destroy: function ()
{
this.reset();

View file

@ -32,8 +32,6 @@ var AnimationJSONFile = function (key, url, path, xhrSettings)
* The file is **not** loaded immediately after calling this method.
* Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts.
*
*
*
* @method Phaser.Loader.LoaderPlugin#animation
* @since 3.0.0
*

View file

@ -33,6 +33,25 @@ var AtlasJSONFile = function (key, textureURL, atlasURL, path, textureXhrSetting
return { texture: image, data: data };
};
/**
* Adds a Texture Atlas file to the current load queue.
*
* Note: This method will only be available if the Atlas JSON File type has been built into Phaser.
*
* The file is **not** loaded immediately after calling this method.
* Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts.
*
* @method Phaser.Loader.LoaderPlugin#atlas
* @since 3.0.0
*
* @param {string} key - The key of the file within the loader.
* @param {string} textureURL - The url to load the texture file from.
* @param {string} atlasURL - The url to load the atlas file from.
* @param {object} textureXhrSettings - Optional texture file specific XHR settings.
* @param {object} atlasXhrSettings - Optional atlas file specific XHR settings.
*
* @return {Phaser.Loader.LoaderPlugin} The Loader.
*/
FileTypesManager.register('atlas', function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings)
{
// Returns an object with two properties: 'texture' and 'data'

View file

@ -95,16 +95,6 @@ AudioFile.create = function (loader, key, urls, config, xhrSettings)
var audioConfig = game.config.audio;
var deviceAudio = game.device.audio;
/**
* [description]
*
* @method Phaser.Loader.FileTypes.AudioFile#
* @since 3.0.0
*
* @param {[type]} (audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData) - [description]
*
* @return {[type]} [description]
*/
if ((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData))
{
console.info('Skipping loading audio \'' + key + '\' since sounds are disabled.');
@ -113,68 +103,44 @@ AudioFile.create = function (loader, key, urls, config, xhrSettings)
var url = AudioFile.findAudioURL(game, urls);
/**
* [description]
*
* @method Phaser.Loader.FileTypes.AudioFile#
* @since 3.0.0
*
* @param {[type]} !url - [description]
*
* @return {[type]} [description]
*/
if (!url)
{
console.warn('No supported url provided for audio \'' + key + '\'!');
return null;
}
/**
* [description]
*
* @method Phaser.Loader.FileTypes.AudioFile#
* @since 3.0.0
*
* @param {[type]} deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio) - [description]
*
* @return {[type]} [description]
*/
if (deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio))
{
return new AudioFile(key, url, loader.path, xhrSettings, game.sound.context);
}
/**
* [description]
*
* @method Phaser.Loader.FileTypes.AudioFile#
* @since 3.0.0
*
* @return {[type]} [description]
*/
else
{
return new HTML5AudioFile(key, url, loader.path, config, game.sound.locked);
}
};
// When registering a factory function 'this' refers to the Loader context.
//
// There are several properties available to use:
//
// this.scene - a reference to the Scene that owns the GameObjectFactory
/**
* Adds an Audio file to the current load queue.
*
* Note: This method will only be available if the Audio File type has been built into Phaser.
*
* The file is **not** loaded immediately after calling this method.
* Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts.
*
* @method Phaser.Loader.LoaderPlugin#audio
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string|string[]} urls - [description]
* @param {object} config - [description]
* @param {object} xhrSettings - [description]
*
* @return {Phaser.Loader.LoaderPlugin} The Loader.
*/
FileTypesManager.register('audio', function (key, urls, config, xhrSettings)
{
var audioFile = AudioFile.create(this, key, urls, config, xhrSettings);
/**
* [description]
*
* @method Phaser.Loader.FileTypes.AudioFile#
* @since 3.0.0
*
* @param {[type]} audioFile - [description]
*/
if (audioFile)
{
this.addFile(audioFile);
@ -229,29 +195,11 @@ FileTypesManager.register('audio', function (key, urls, config, xhrSettings)
AudioFile.findAudioURL = function (game, urls)
{
/**
* [description]
*
* @method Phaser.Loader.FileTypes.AudioFile#
* @since 3.0.0
*
* @param {[type]} urls.constructor !== Array - [description]
*/
if (urls.constructor !== Array)
{
urls = [ urls ];
}
/**
* [description]
*
* @method Phaser.Loader.FileTypes.AudioFile#
* @since 3.0.0
*
* @param {[type]} var i = 0; i < urls.length; i++ - [description]
*
* @return {[type]} [description]
*/
for (var i = 0; i < urls.length; i++)
{
var url = GetFastValue(urls[i], 'uri', urls[i]);

View file

@ -3,8 +3,26 @@ var CONST = require('../const');
var FileTypesManager = require('../FileTypesManager');
var JSONFile = require('./JSONFile.js');
// Phaser.Loader.FileTypes.AudioSprite
/**
* Adds an Audio Sprite file to the current load queue.
*
* Note: This method will only be available if the Audio Sprite File type has been built into Phaser.
*
* The file is **not** loaded immediately after calling this method.
* Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts.
*
* @method Phaser.Loader.LoaderPlugin#audioSprite
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string|string[]} urls - [description]
* @param {object} json - [description]
* @param {object} config - [description]
* @param {object} audioXhrSettings - Optional file specific XHR settings.
* @param {object} jsonXhrSettings - Optional file specific XHR settings.
*
* @return {Phaser.Loader.LoaderPlugin} The Loader.
*/
FileTypesManager.register('audioSprite', function (key, urls, json, config, audioXhrSettings, jsonXhrSettings)
{
var audioFile = AudioFile.create(this, key, urls, config, audioXhrSettings);

View file

@ -4,8 +4,21 @@ var File = require('../File');
var FileTypesManager = require('../FileTypesManager');
var GetFastValue = require('../../utils/object/GetFastValue');
// Phaser.Loader.FileTypes.BinaryFile
/**
* @classdesc
* [description]
*
* @class BinaryFile
* @extends Phaser.Loader.File
* @memberOf Phaser.Loader.FileTypes
* @constructor
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string} url - [description]
* @param {string} path - [description]
* @param {object} xhrSettings - [description]
*/
var BinaryFile = new Class({
Extends: File,
@ -42,12 +55,23 @@ var BinaryFile = new Class({
});
// When registering a factory function 'this' refers to the Loader context.
//
// There are several properties available to use:
//
// this.scene - a reference to the Scene that owns the GameObjectFactory
/**
* Adds Binary file to the current load queue.
*
* Note: This method will only be available if the Binary File type has been built into Phaser.
*
* The file is **not** loaded immediately after calling this method.
* Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts.
*
* @method Phaser.Loader.LoaderPlugin#binary
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string} url - [description]
* @param {object} xhrSettings - [description]
*
* @return {Phaser.Loader.LoaderPlugin} The Loader.
*/
FileTypesManager.register('binary', function (key, url, xhrSettings)
{
if (Array.isArray(key))

View file

@ -2,6 +2,21 @@ var FileTypesManager = require('../FileTypesManager');
var ImageFile = require('./ImageFile.js');
var XMLFile = require('./XMLFile.js');
/**
* An Bitmap Font File.
*
* @function Phaser.Loader.Filetypes.BitmapFontFile
* @since 3.0.0
*
* @param {string} key - The key of the file within the loader.
* @param {string} textureURL - The url to load the texture file from.
* @param {string} xmlURL - The url to load the atlas file from.
* @param {string} path - The path of the file.
* @param {object} textureXhrSettings - Optional texture file specific XHR settings.
* @param {object} xmlXhrSettings - Optional atlas file specific XHR settings.
*
* @return {object} An object containing two File objects to be added to the loader.
*/
var BitmapFontFile = function (key, textureURL, xmlURL, path, textureXhrSettings, xmlXhrSettings)
{
var image = new ImageFile(key, textureURL, path, textureXhrSettings);
@ -18,12 +33,25 @@ var BitmapFontFile = function (key, textureURL, xmlURL, path, textureXhrSettings
return { texture: image, data: data };
};
// When registering a factory function 'this' refers to the Loader context.
//
// There are several properties available to use:
//
// this.scene - a reference to the Scene that owns the GameObjectFactory
/**
* Adds a Bitmap Font file to the current load queue.
*
* Note: This method will only be available if the Bitmap Font File type has been built into Phaser.
*
* The file is **not** loaded immediately after calling this method.
* Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts.
*
* @method Phaser.Loader.LoaderPlugin#bitmapFont
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string} textureURL - [description]
* @param {string} xmlURL - [description]
* @param {object} textureXhrSettings - [description]
* @param {object} xmlXhrSettings - [description]
*
* @return {Phaser.Loader.LoaderPlugin} The Loader.
*/
FileTypesManager.register('bitmapFont', function (key, textureURL, xmlURL, textureXhrSettings, xmlXhrSettings)
{
// Returns an object with two properties: 'texture' and 'data'

View file

@ -4,8 +4,21 @@ var File = require('../File');
var FileTypesManager = require('../FileTypesManager');
var GetFastValue = require('../../utils/object/GetFastValue');
// Phaser.Loader.FileTypes.GLSLFile
/**
* @classdesc
* [description]
*
* @class GLSLFile
* @extends Phaser.Loader.File
* @memberOf Phaser.Loader.FileTypes
* @constructor
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string} url - [description]
* @param {string} path - [description]
* @param {object} xhrSettings - [description]
*/
var GLSLFile = new Class({
Extends: File,
@ -42,12 +55,23 @@ var GLSLFile = new Class({
});
// When registering a factory function 'this' refers to the Loader context.
//
// There are several properties available to use:
//
// this.scene - a reference to the Scene that owns the GameObjectFactory
/**
* Adds a GLSL file to the current load queue.
*
* Note: This method will only be available if the GLSL File type has been built into Phaser.
*
* The file is **not** loaded immediately after calling this method.
* Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts.
*
* @method Phaser.Loader.LoaderPlugin#glsl
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string} url - [description]
* @param {object} xhrSettings - [description]
*
* @return {Phaser.Loader.LoaderPlugin} The Loader.
*/
FileTypesManager.register('glsl', function (key, url, xhrSettings)
{
if (Array.isArray(key))

View file

@ -3,8 +3,22 @@ var File = require('../File');
var GetFastValue = require('../../utils/object/GetFastValue');
var GetURL = require('../GetURL');
// Phaser.Loader.FileTypes.HTML5AudioFile
/**
* @classdesc
* [description]
*
* @class HTML5AudioFile
* @extends Phaser.Loader.File
* @memberOf Phaser.Loader.FileTypes
* @constructor
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string} url - [description]
* @param {string} path - [description]
* @param {object} config - [description]
* @param {boolean} locked - [description]
*/
var HTML5AudioFile = new Class({
Extends: File,

View file

@ -4,8 +4,23 @@ var File = require('../File');
var FileTypesManager = require('../FileTypesManager');
var GetFastValue = require('../../utils/object/GetFastValue');
// Phaser.Loader.FileTypes.HTMLFile
/**
* @classdesc
* [description]
*
* @class HTMLFile
* @extends Phaser.Loader.File
* @memberOf Phaser.Loader.FileTypes
* @constructor
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string} url - [description]
* @param {number} width - [description]
* @param {number} height - [description]
* @param {string} path - [description]
* @param {object} xhrSettings - [description]
*/
var HTMLFile = new Class({
Extends: File,
@ -96,12 +111,25 @@ var HTMLFile = new Class({
});
// When registering a factory function 'this' refers to the Loader context.
//
// There are several properties available to use:
//
// this.scene - a reference to the Scene that owns the GameObjectFactory
/**
* Adds an HTML file to the current load queue.
*
* Note: This method will only be available if the HTML File type has been built into Phaser.
*
* The file is **not** loaded immediately after calling this method.
* Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts.
*
* @method Phaser.Loader.LoaderPlugin#html
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string} url - [description]
* @param {number} width - [description]
* @param {number} height - [description]
* @param {object} xhrSettings - [description]
*
* @return {Phaser.Loader.LoaderPlugin} The Loader.
*/
FileTypesManager.register('html', function (key, url, width, height, xhrSettings)
{
if (Array.isArray(key))

View file

@ -4,8 +4,22 @@ var File = require('../File');
var FileTypesManager = require('../FileTypesManager');
var GetFastValue = require('../../utils/object/GetFastValue');
// Phaser.Loader.FileTypes.ImageFile
/**
* @classdesc
* [description]
*
* @class ImageFile
* @extends Phaser.Loader.File
* @memberOf Phaser.Loader.FileTypes
* @constructor
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string} url - [description]
* @param {string} path - [description]
* @param {object} xhrSettings - [description]
* @param {object} config - [description]
*/
var ImageFile = new Class({
Extends: File,
@ -79,25 +93,40 @@ var ImageFile = new Class({
});
// When registering a factory function 'this' refers to the Loader context.
//
// There are several properties available to use:
//
// this.scene - a reference to the Scene that owns the GameObjectFactory
/**
* Adds an Image file to the current load queue.
*
* Note: This method will only be available if the Image File type has been built into Phaser.
*
* The file is **not** loaded immediately after calling this method.
* Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts.
*
* @method Phaser.Loader.LoaderPlugin#image
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string} url - [description]
* @param {object} xhrSettings - [description]
*
* @return {Phaser.Loader.LoaderPlugin} The Loader.
*/
FileTypesManager.register('image', function (key, url, xhrSettings)
{
var urls;
var fileA;
var fileB;
if (Array.isArray(key))
{
for (var i = 0; i < key.length; i++)
{
// If it's an array it has to be an array of Objects, so we get everything out of the 'key' object
var urls = GetFastValue(key[i], 'file', url);
urls = GetFastValue(key[i], 'file', url);
if (Array.isArray(urls) && urls.length === 2)
{
var fileA = this.addFile(new ImageFile(key[i], urls[0], this.path, xhrSettings));
var fileB = this.addFile(new ImageFile(key[i], urls[1], this.path, xhrSettings));
fileA = this.addFile(new ImageFile(key[i], urls[0], this.path, xhrSettings));
fileB = this.addFile(new ImageFile(key[i], urls[1], this.path, xhrSettings));
fileA.setLinkFile(fileB, 'dataimage');
}
@ -109,12 +138,12 @@ FileTypesManager.register('image', function (key, url, xhrSettings)
}
else
{
var urls = GetFastValue(key, 'file', url);
urls = GetFastValue(key, 'file', url);
if (Array.isArray(urls) && urls.length === 2)
{
var fileA = this.addFile(new ImageFile(key, urls[0], this.path, xhrSettings));
var fileB = this.addFile(new ImageFile(key, urls[1], this.path, xhrSettings));
fileA = this.addFile(new ImageFile(key, urls[0], this.path, xhrSettings));
fileB = this.addFile(new ImageFile(key, urls[1], this.path, xhrSettings));
fileA.setLinkFile(fileB, 'dataimage');
}

View file

@ -4,8 +4,21 @@ var File = require('../File');
var FileTypesManager = require('../FileTypesManager');
var GetFastValue = require('../../utils/object/GetFastValue');
// Phaser.Loader.FileTypes.JSONFile
/**
* @classdesc
* [description]
*
* @class JSONFile
* @extends Phaser.Loader.File
* @memberOf Phaser.Loader.FileTypes
* @constructor
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string} url - [description]
* @param {string} path - [description]
* @param {object} xhrSettings - [description]
*/
var JSONFile = new Class({
Extends: File,
@ -52,12 +65,23 @@ var JSONFile = new Class({
});
// When registering a factory function 'this' refers to the Loader context.
//
// There are several properties available to use:
//
// this.scene - a reference to the Scene that owns the GameObjectFactory
/**
* Adds a JSON file to the current load queue.
*
* Note: This method will only be available if the JSON File type has been built into Phaser.
*
* The file is **not** loaded immediately after calling this method.
* Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts.
*
* @method Phaser.Loader.LoaderPlugin#json
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string} url - [description]
* @param {object} xhrSettings - [description]
*
* @return {Phaser.Loader.LoaderPlugin} The Loader.
*/
FileTypesManager.register('json', function (key, url, xhrSettings)
{
if (Array.isArray(key))

View file

@ -3,8 +3,25 @@ var ImageFile = require('./ImageFile.js');
var JSONFile = require('./JSONFile.js');
var NumberArray = require('../../utils/array/NumberArray');
// Phaser.Loader.FileTypes.MultiAtlas
/**
* Adds a Multi File Texture Atlas to the current load queue.
*
* Note: This method will only be available if the Multi Atlas File type has been built into Phaser.
*
* The file is **not** loaded immediately after calling this method.
* Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts.
*
* @method Phaser.Loader.LoaderPlugin#multiatlas
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string[]} textureURLs - [description]
* @param {string[]} atlasURLs - [description]
* @param {object} textureXhrSettings - [description]
* @param {object} atlasXhrSettings - [description]
*
* @return {Phaser.Loader.LoaderPlugin} The Loader.
*/
FileTypesManager.register('multiatlas', function (key, textureURLs, atlasURLs, textureXhrSettings, atlasXhrSettings)
{
if (typeof textureURLs === 'number')

View file

@ -5,8 +5,21 @@ var FileTypesManager = require('../FileTypesManager');
var GetFastValue = require('../../utils/object/GetFastValue');
var PluginManager = require('../../plugins/PluginManager');
// Phaser.Loader.FileTypes.PluginFile
/**
* @classdesc
* [description]
*
* @class PluginFile
* @extends Phaser.Loader.File
* @memberOf Phaser.Loader.FileTypes
* @constructor
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string} url - [description]
* @param {string} path - [description]
* @param {object} xhrSettings - [description]
*/
var PluginFile = new Class({
Extends: File,
@ -52,12 +65,23 @@ var PluginFile = new Class({
});
// When registering a factory function 'this' refers to the Loader context.
//
// There are several properties available to use:
//
// this.scene - a reference to the Scene that owns the GameObjectFactory
/**
* Adds a Plugin file to the current load queue.
*
* Note: This method will only be available if the Plugin File type has been built into Phaser.
*
* The file is **not** loaded immediately after calling this method.
* Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts.
*
* @method Phaser.Loader.LoaderPlugin#plugin
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string} url - [description]
* @param {object} xhrSettings - [description]
*
* @return {Phaser.Loader.LoaderPlugin} The Loader.
*/
FileTypesManager.register('plugin', function (key, url, xhrSettings)
{
if (Array.isArray(key))

View file

@ -4,8 +4,21 @@ var File = require('../File');
var FileTypesManager = require('../FileTypesManager');
var GetFastValue = require('../../utils/object/GetFastValue');
// Phaser.Loader.FileTypes.SVGFile
/**
* @classdesc
* [description]
*
* @class SVGFile
* @extends Phaser.Loader.File
* @memberOf Phaser.Loader.FileTypes
* @constructor
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string} url - [description]
* @param {string} path - [description]
* @param {object} xhrSettings - [description]
*/
var SVGFile = new Class({
Extends: File,
@ -91,12 +104,23 @@ var SVGFile = new Class({
});
// When registering a factory function 'this' refers to the Loader context.
//
// There are several properties available to use:
//
// this.scene - a reference to the Scene that owns the GameObjectFactory
/**
* Adds an SVG file to the current load queue.
*
* Note: This method will only be available if the SVG File type has been built into Phaser.
*
* The file is **not** loaded immediately after calling this method.
* Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts.
*
* @method Phaser.Loader.LoaderPlugin#svg
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string} url - [description]
* @param {object} xhrSettings - [description]
*
* @return {Phaser.Loader.LoaderPlugin} The Loader.
*/
FileTypesManager.register('svg', function (key, url, xhrSettings)
{
if (Array.isArray(key))

View file

@ -4,8 +4,21 @@ var File = require('../File');
var FileTypesManager = require('../FileTypesManager');
var GetFastValue = require('../../utils/object/GetFastValue');
// Phaser.Loader.FileTypes.ScriptFile
/**
* @classdesc
* [description]
*
* @class ScriptFile
* @extends Phaser.Loader.File
* @memberOf Phaser.Loader.FileTypes
* @constructor
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string} url - [description]
* @param {string} path - [description]
* @param {object} xhrSettings - [description]
*/
var ScriptFile = new Class({
Extends: File,
@ -48,12 +61,23 @@ var ScriptFile = new Class({
});
// When registering a factory function 'this' refers to the Loader context.
//
// There are several properties available to use:
//
// this.scene - a reference to the Scene that owns the GameObjectFactory
/**
* Adds a JavaScript file to the current load queue.
*
* Note: This method will only be available if the Script File type has been built into Phaser.
*
* The file is **not** loaded immediately after calling this method.
* Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts.
*
* @method Phaser.Loader.LoaderPlugin#script
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string} url - [description]
* @param {object} xhrSettings - [description]
*
* @return {Phaser.Loader.LoaderPlugin} The Loader.
*/
FileTypesManager.register('script', function (key, url, xhrSettings)
{
if (Array.isArray(key))

View file

@ -1,42 +0,0 @@
var FileTypesManager = require('../FileTypesManager');
var ImageFile = require('./ImageFile.js');
// config can include: frameWidth, frameHeight, startFrame, endFrame, margin, spacing
var SpriteSheet = function (key, url, config, path, xhrSettings)
{
var image = new ImageFile(key, url, path, xhrSettings, config);
// Override the File type
image.type = 'spritesheet';
return image;
};
// When registering a factory function 'this' refers to the Loader context.
//
// There are several properties available to use:
//
// this.scene - a reference to the Scene that owns the GameObjectFactory
// config can include: frameWidth, frameHeight, startFrame, endFrame, margin, spacing
FileTypesManager.register('spritesheet', function (key, url, config, xhrSettings)
{
if (Array.isArray(key))
{
for (var i = 0; i < key.length; i++)
{
// If it's an array it has to be an array of Objects, so we get everything out of the 'key' object
this.addFile(new SpriteSheet(key[i], url, null, this.path, xhrSettings));
}
}
else
{
this.addFile(new SpriteSheet(key, url, config, this.path, xhrSettings));
}
// For method chaining
return this;
});
module.exports = SpriteSheet;

View file

@ -0,0 +1,65 @@
var FileTypesManager = require('../FileTypesManager');
var ImageFile = require('./ImageFile.js');
/**
* A Sprite Sheet File.
*
* @function Phaser.Loader.Filetypes.SpriteSheetFile
* @since 3.0.0
*
* @param {string} key - The key of the file within the loader.
* @param {string} url - The url to load the texture file from.
* @param {object} config - Optional texture file specific XHR settings.
* @param {string} path - Optional texture file specific XHR settings.
* @param {object} xhrSettings - Optional atlas file specific XHR settings.
*
* @return {object} An object containing two File objects to be added to the loader.
*/
var SpriteSheetFile = function (key, url, config, path, xhrSettings)
{
var image = new ImageFile(key, url, path, xhrSettings, config);
// Override the File type
image.type = 'spritesheet';
return image;
};
/**
* Adds a Sprite Sheet file to the current load queue.
*
* Note: This method will only be available if the Sprite Sheet File type has been built into Phaser.
*
* The file is **not** loaded immediately after calling this method.
* Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts.
*
* @method Phaser.Loader.LoaderPlugin#image
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string} url - [description]
* @param {object} config - config can include: frameWidth, frameHeight, startFrame, endFrame, margin, spacing.
* @param {object} xhrSettings - [description]
*
* @return {Phaser.Loader.LoaderPlugin} The Loader.
*/
FileTypesManager.register('spritesheet', function (key, url, config, xhrSettings)
{
if (Array.isArray(key))
{
for (var i = 0; i < key.length; i++)
{
// If it's an array it has to be an array of Objects, so we get everything out of the 'key' object
this.addFile(new SpriteSheetFile(key[i], url, null, this.path, xhrSettings));
}
}
else
{
this.addFile(new SpriteSheetFile(key, url, config, this.path, xhrSettings));
}
// For method chaining
return this;
});
module.exports = SpriteSheetFile;

View file

@ -3,8 +3,21 @@ var CONST = require('../const');
var File = require('../File');
var FileTypesManager = require('../FileTypesManager');
// Phaser.Loader.FileTypes.TextFile
/**
* @classdesc
* [description]
*
* @class TextFile
* @extends Phaser.Loader.File
* @memberOf Phaser.Loader.FileTypes
* @constructor
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string} url - [description]
* @param {string} path - [description]
* @param {object} xhrSettings - [description]
*/
var TextFile = new Class({
Extends: File,
@ -39,12 +52,23 @@ var TextFile = new Class({
});
// When registering a factory function 'this' refers to the Loader context.
//
// There are several properties available to use:
//
// this.scene - a reference to the Scene that owns the GameObjectFactory
/**
* Adds a Text file to the current load queue.
*
* Note: This method will only be available if the Text File type has been built into Phaser.
*
* The file is **not** loaded immediately after calling this method.
* Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts.
*
* @method Phaser.Loader.LoaderPlugin#text
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string} url - [description]
* @param {object} xhrSettings - [description]
*
* @return {Phaser.Loader.LoaderPlugin} The Loader.
*/
FileTypesManager.register('text', function (key, url, xhrSettings)
{
if (Array.isArray(key))

View file

@ -4,8 +4,22 @@ var File = require('../File');
var FileTypesManager = require('../FileTypesManager');
var TILEMAP_FORMATS = require('../../tilemaps/Formats');
// Phaser.Loader.FileTypes.TilemapCSVFile
/**
* @classdesc
* [description]
*
* @class TilemapCSVFile
* @extends Phaser.Loader.File
* @memberOf Phaser.Loader.FileTypes
* @constructor
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string} url - [description]
* @param {string} path - [description]
* @param {string} format - [description]
* @param {object} xhrSettings - [description]
*/
var TilemapCSVFile = new Class({
Extends: File,
@ -42,12 +56,23 @@ var TilemapCSVFile = new Class({
});
// When registering a factory function 'this' refers to the Loader context.
//
// There are several properties available to use:
//
// this.scene - a reference to the Scene that owns the GameObjectFactory
/**
* Adds a Tilemap CSV file to the current load queue.
*
* Note: This method will only be available if the Tilemap CSV File type has been built into Phaser.
*
* The file is **not** loaded immediately after calling this method.
* Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts.
*
* @method Phaser.Loader.LoaderPlugin#tilemapCSV
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string} url - [description]
* @param {object} xhrSettings - [description]
*
* @return {Phaser.Loader.LoaderPlugin} The Loader.
*/
FileTypesManager.register('tilemapCSV', function (key, url, xhrSettings)
{
if (Array.isArray(key))

View file

@ -2,8 +2,20 @@ var FileTypesManager = require('../FileTypesManager');
var JSONFile = require('./JSONFile.js');
var TILEMAP_FORMATS = require('../../tilemaps/Formats');
// Phaser.Loader.FileTypes.TilemapJSONFile
/**
* A Tilemap File.
*
* @function Phaser.Loader.Filetypes.TilemapJSONFile
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string} url - [description]
* @param {string} path - [description]
* @param {string} format - [description]
* @param {object} xhrSettings - [description]
*
* @return {object} An object containing two File objects to be added to the loader.
*/
var TilemapJSONFile = function (key, url, path, format, xhrSettings)
{
var json = new JSONFile(key, url, path, xhrSettings);
@ -16,12 +28,23 @@ var TilemapJSONFile = function (key, url, path, format, xhrSettings)
return json;
};
// When registering a factory function 'this' refers to the Loader context.
//
// There are several properties available to use:
//
// this.scene - a reference to the Scene that owns the GameObjectFactory
/**
* Adds a Tilemap (Tiled JSON Format) file to the current load queue.
*
* Note: This method will only be available if the Tilemap File type has been built into Phaser.
*
* The file is **not** loaded immediately after calling this method.
* Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts.
*
* @method Phaser.Loader.LoaderPlugin#tilemapTiledJSON
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string} url - [description]
* @param {object} xhrSettings - [description]
*
* @return {Phaser.Loader.LoaderPlugin} The Loader.
*/
FileTypesManager.register('tilemapTiledJSON', function (key, url, xhrSettings)
{
if (Array.isArray(key))
@ -41,6 +64,23 @@ FileTypesManager.register('tilemapTiledJSON', function (key, url, xhrSettings)
return this;
});
/**
* Adds a Tilemap (Weltmeister Format) file to the current load queue.
*
* Note: This method will only be available if the Tilemap File type has been built into Phaser.
*
* The file is **not** loaded immediately after calling this method.
* Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts.
*
* @method Phaser.Loader.LoaderPlugin#tilemapWeltmeister
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string} url - [description]
* @param {object} xhrSettings - [description]
*
* @return {Phaser.Loader.LoaderPlugin} The Loader.
*/
FileTypesManager.register('tilemapWeltmeister', function (key, url, xhrSettings)
{
if (Array.isArray(key))

View file

@ -2,6 +2,21 @@ var FileTypesManager = require('../FileTypesManager');
var ImageFile = require('./ImageFile.js');
var TextFile = require('./TextFile.js');
/**
* An Atlas JSON File.
*
* @function Phaser.Loader.Filetypes.UnityAtlasFile
* @since 3.0.0
*
* @param {string} key - The key of the file within the loader.
* @param {string} textureURL - The url to load the texture file from.
* @param {string} atlasURL - The url to load the atlas file from.
* @param {string} path - The path of the file.
* @param {object} textureXhrSettings - Optional texture file specific XHR settings.
* @param {object} atlasXhrSettings - Optional atlas file specific XHR settings.
*
* @return {object} An object containing two File objects to be added to the loader.
*/
var UnityAtlasFile = function (key, textureURL, atlasURL, path, textureXhrSettings, atlasXhrSettings)
{
var image = new ImageFile(key, textureURL, path, textureXhrSettings);
@ -18,12 +33,25 @@ var UnityAtlasFile = function (key, textureURL, atlasURL, path, textureXhrSettin
return { texture: image, data: data };
};
// When registering a factory function 'this' refers to the Loader context.
//
// There are several properties available to use:
//
// this.scene - a reference to the Scene that owns the GameObjectFactory
/**
* Adds a Unity Texture Atlas file to the current load queue.
*
* Note: This method will only be available if the Unity Atlas File type has been built into Phaser.
*
* The file is **not** loaded immediately after calling this method.
* Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts.
*
* @method Phaser.Loader.LoaderPlugin#unityAtlas
* @since 3.0.0
*
* @param {string} key - The key of the file within the loader.
* @param {string} textureURL - The url to load the texture file from.
* @param {string} atlasURL - The url to load the atlas file from.
* @param {object} textureXhrSettings - Optional texture file specific XHR settings.
* @param {object} atlasXhrSettings - Optional atlas file specific XHR settings.
*
* @return {Phaser.Loader.LoaderPlugin} The Loader.
*/
FileTypesManager.register('unityAtlas', function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings)
{
// Returns an object with two properties: 'texture' and 'data'

View file

@ -5,8 +5,21 @@ var FileTypesManager = require('../FileTypesManager');
var GetFastValue = require('../../utils/object/GetFastValue');
var ParseOBJ = require('../../geom/mesh/ParseOBJ');
// Phaser.Loader.FileTypes.WavefrontFile
/**
* @classdesc
* [description]
*
* @class WavefrontFile
* @extends Phaser.Loader.File
* @memberOf Phaser.Loader.FileTypes
* @constructor
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string} url - [description]
* @param {string} path - [description]
* @param {object} xhrSettings - [description]
*/
var WavefrontFile = new Class({
Extends: File,
@ -43,12 +56,23 @@ var WavefrontFile = new Class({
});
// When registering a factory function 'this' refers to the Loader context.
//
// There are several properties available to use:
//
// this.scene - a reference to the Scene that owns the GameObjectFactory
/**
* Adds a Wavefront OBK file to the current load queue.
*
* Note: This method will only be available if the file type has been built into Phaser.
*
* The file is **not** loaded immediately after calling this method.
* Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts.
*
* @method Phaser.Loader.LoaderPlugin#obj
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string} url - [description]
* @param {object} xhrSettings - [description]
*
* @return {Phaser.Loader.LoaderPlugin} The Loader.
*/
FileTypesManager.register('obj', function (key, url, xhrSettings)
{
if (Array.isArray(key))

View file

@ -5,8 +5,21 @@ var FileTypesManager = require('../FileTypesManager');
var GetFastValue = require('../../utils/object/GetFastValue');
var ParseXML = require('../../dom/ParseXML');
// Phaser.Loader.FileTypes.XMLFile
/**
* @classdesc
* [description]
*
* @class XMLFile
* @extends Phaser.Loader.File
* @memberOf Phaser.Loader.FileTypes
* @constructor
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string} url - [description]
* @param {string} path - [description]
* @param {object} xhrSettings - [description]
*/
var XMLFile = new Class({
Extends: File,
@ -48,12 +61,23 @@ var XMLFile = new Class({
});
// When registering a factory function 'this' refers to the Loader context.
//
// There are several properties available to use:
//
// this.scene - a reference to the Scene that owns the GameObjectFactory
/**
* Adds an XML file to the current load queue.
*
* Note: This method will only be available if the XML File type has been built into Phaser.
*
* The file is **not** loaded immediately after calling this method.
* Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts.
*
* @method Phaser.Loader.LoaderPlugin#xml
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string} url - [description]
* @param {object} xhrSettings - [description]
*
* @return {Phaser.Loader.LoaderPlugin} The Loader.
*/
FileTypesManager.register('xml', function (key, url, xhrSettings)
{
if (Array.isArray(key))

View file

@ -41,7 +41,7 @@ module.exports = {
MultiAtlas: require('./MultiAtlas'),
PluginFile: require('./PluginFile'),
ScriptFile: require('./ScriptFile'),
SpriteSheet: require('./SpriteSheet'),
SpriteSheetFile: require('./SpriteSheetFile'),
SVGFile: require('./SVGFile'),
TextFile: require('./TextFile'),
TilemapCSVFile: require('./TilemapCSVFile'),

View file

@ -59,10 +59,10 @@ var Body = new Class({
this.enabled = true;
/**
* [description]
* The ImpactBody, ImpactSprite or ImpactImage object that owns this Body, if any.
*
* @name Phaser.Physics.Impact.Body#parent
* @type {null}
* @type {Phaser.Physics.Impact.ImpactBody|Phaser.Physics.Impact.ImpactImage|Phaser.Physics.Impact.ImpactSprite|null}
* @since 3.0.0
*/
this.parent;
@ -505,7 +505,7 @@ var Body = new Class({
* [description]
*
* @method Phaser.Physics.Impact.Body#fromJSON
* @todo
* @todo Code it!
* @since 3.0.0
*
* @param {object} config - [description]

View file

@ -1,8 +1,18 @@
// Phaser.Physics.Impact.CollisionMap
var Class = require('../../utils/Class');
var DefaultDefs = require('./DefaultDefs');
/**
* @classdesc
* [description]
*
* @class CollisionMap
* @memberOf Phaser.Physics.Impact
* @constructor
* @since 3.0.0
*
* @param {integer} [tilesize=32] - [description]
* @param {array} data - [description]
*/
var CollisionMap = new Class({
initialize:
@ -11,18 +21,78 @@ var CollisionMap = new Class({
{
if (tilesize === undefined) { tilesize = 32; }
/**
* [description]
*
* @name Phaser.Physics.Impact.CollisionMap#tilesize
* @type {integer}
* @default 32
* @since 3.0.0
*/
this.tilesize = tilesize;
/**
* [description]
*
* @name Phaser.Physics.Impact.CollisionMap#data
* @type {array}
* @since 3.0.0
*/
this.data = (Array.isArray(data)) ? data : [];
/**
* [description]
*
* @name Phaser.Physics.Impact.CollisionMap#width
* @type {number}
* @since 3.0.0
*/
this.width = (Array.isArray(data)) ? data[0].length : 0;
/**
* [description]
*
* @name Phaser.Physics.Impact.CollisionMap#height
* @type {number}
* @since 3.0.0
*/
this.height = (Array.isArray(data)) ? data.length : 0;
/**
* [description]
*
* @name Phaser.Physics.Impact.CollisionMap#lastSlope
* @type {integer}
* @default 55
* @since 3.0.0
*/
this.lastSlope = 55;
/**
* [description]
*
* @name Phaser.Physics.Impact.CollisionMap#tiledef
* @type {object}
* @since 3.0.0
*/
this.tiledef = DefaultDefs;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.CollisionMap#trace
* @since 3.0.0
*
* @param {number} x - [description]
* @param {number} y - [description]
* @param {number} vx - [description]
* @param {number} vy - [description]
* @param {number} objectWidth - [description]
* @param {number} objectHeight - [description]
*
* @return {boolean} [description]
*/
trace: function (x, y, vx, vy, objectWidth, objectHeight)
{
// Set up the trace-result
@ -77,6 +147,23 @@ var CollisionMap = new Class({
return res;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.CollisionMap#step
* @since 3.0.0
*
* @param {object} res - [description]
* @param {number} x - [description]
* @param {number} y - [description]
* @param {number} vx - [description]
* @param {number} vy - [description]
* @param {number} width - [description]
* @param {number} height - [description]
* @param {number} rvx - [description]
* @param {number} rvy - [description]
* @param {number} step - [description]
*/
step: function (res, x, y, vx, vy, width, height, rvx, rvy, step)
{
var t = 0;
@ -191,6 +278,25 @@ var CollisionMap = new Class({
}
},
/**
* [description]
*
* @method Phaser.Physics.Impact.CollisionMap#checkDef
* @since 3.0.0
*
* @param {object} res - [description]
* @param {number} t - [description]
* @param {number} x - [description]
* @param {number} y - [description]
* @param {number} vx - [description]
* @param {number} vy - [description]
* @param {number} width - [description]
* @param {number} height - [description]
* @param {number} tileX - [description]
* @param {number} tileY - [description]
*
* @return {boolean} [description]
*/
checkDef: function (res, t, x, y, vx, vy, width, height, tileX, tileY)
{
var def = this.tiledef[t];

View file

@ -3,22 +3,71 @@ var ImpactBody = require('./ImpactBody');
var ImpactImage = require('./ImpactImage');
var ImpactSprite = require('./ImpactSprite');
/**
* @classdesc
* The Impact Physics Factory allows you to easily create Impact Physics enabled Game Objects.
* Objects that are created by this Factory are automatically added to the physics world.
*
* @class Factory
* @memberOf Phaser.Physics.Impact
* @constructor
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.World} world - [description]
*/
var Factory = new Class({
initialize:
function Factory (world)
{
/**
* [description]
*
* @name Phaser.Physics.Impact.Factory#world
* @type {Phaser.Physics.Impact.World}
* @since 3.0.0
*/
this.world = world;
/**
* A reference to the Scene.Systems this Impact Physics instance belongs to.
*
* @name Phaser.Physics.Impact.Factory#sys
* @type {Phaser.Scenes.Systems}
* @since 3.0.0
*/
this.sys = world.scene.sys;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Factory#body
* @since 3.0.0
*
* @param {number} x - [description]
* @param {number} y - [description]
* @param {number} width - [description]
* @param {number} height - [description]
*
* @return {Phaser.Physics.Impact.ImpactBody} The ImpactBody object that was created.
*/
body: function (x, y, width, height)
{
return new ImpactBody(this.world, x, y, width, height);
},
/**
* Adds an Impact Physics Body to the given Game Object.
*
* @method Phaser.Physics.Impact.Factory#existing
* @since 3.0.0
*
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
*
* @return {Phaser.GameObjects.GameObject} The Game Object.
*/
existing: function (gameObject)
{
var x = gameObject.x - gameObject.frame.centerX;
@ -34,6 +83,19 @@ var Factory = new Class({
return gameObject;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Factory#image
* @since 3.0.0
*
* @param {number} x - The horizontal position of this Game Object in the world.
* @param {number} y - The vertical position of this Game Object in the world.
* @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
* @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with.
*
* @return {Phaser.Physics.Impact.ImpactImage} The ImpactImage object that was created.
*/
image: function (x, y, key, frame)
{
var image = new ImpactImage(this.world, x, y, key, frame);
@ -43,6 +105,19 @@ var Factory = new Class({
return image;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.Factory#sprite
* @since 3.0.0
*
* @param {number} x - The horizontal position of this Game Object in the world.
* @param {number} y - The vertical position of this Game Object in the world.
* @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
* @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with.
*
* @return {Phaser.Physics.Impact.ImpactSprite} The ImpactSprite object that was created.
*/
sprite: function (x, y, key, frame)
{
var sprite = new ImpactSprite(this.world, x, y, key, frame);

View file

@ -1,5 +1,19 @@
var Clamp = require('../../math/Clamp');
/**
* [description]
*
* @function Phaser.Physics.Impact.GetVelocity
* @since 3.0.0
*
* @param {number} delta - [description]
* @param {number} vel - [description]
* @param {number} accel - [description]
* @param {number} friction - [description]
* @param {number} max - [description]
*
* @return {number} [description]
*/
var GetVelocity = function (delta, vel, accel, friction, max)
{
if (accel)

View file

@ -1,7 +1,34 @@
var Class = require('../../utils/Class');
var Components = require('./components');
/**
* @classdesc
* [description]
*
* @class ImpactBody
* @memberOf Phaser.Physics.Impact
* @constructor
* @since 3.0.0
*
* @extends Phaser.Physics.Impact.Components.Acceleration
* @extends Phaser.Physics.Impact.Components.BodyScale
* @extends Phaser.Physics.Impact.Components.BodyType
* @extends Phaser.Physics.Impact.Components.Bounce
* @extends Phaser.Physics.Impact.Components.CheckAgainst
* @extends Phaser.Physics.Impact.Components.Collides
* @extends Phaser.Physics.Impact.Components.Debug
* @extends Phaser.Physics.Impact.Components.Friction
* @extends Phaser.Physics.Impact.Components.Gravity
* @extends Phaser.Physics.Impact.Components.Offset
* @extends Phaser.Physics.Impact.Components.SetGameObject
* @extends Phaser.Physics.Impact.Components.Velocity
*
* @param {Phaser.Physics.Impact.World} world - [description]
* @param {number} x - [description]
* @param {number} y - [description]
* @param {number} width - [description]
* @param {number} height - [description]
*/
var ImpactBody = new Class({
Mixins: [
@ -21,19 +48,71 @@ var ImpactBody = new Class({
initialize:
// x/y is the top-left of the Body
function ImpactBody (world, x, y, width, height)
{
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactBody#body
* @type {Phaser.Physics.Impact.Body}
* @since 3.0.0
*/
this.body = world.create(x, y, width, height);
this.body.parent = this;
// Local references to the Body properties
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactBody#size
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.size = this.body.size;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactBody#offset
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.offset = this.body.offset;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactBody#vel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.vel = this.body.vel;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactBody#accel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.accel = this.body.accel;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactBody#friction
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.friction = this.body.friction;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactBody#maxVel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.maxVel = this.body.maxVel;
}

View file

@ -1,8 +1,55 @@
var Class = require('../../utils/Class');
var Components = require('./components');
var Image = require('../../gameobjects/image/Image');
/**
* @classdesc
* An Impact Physics Image Game Object.
*
* An Image is a light-weight Game Object useful for the display of static images in your game,
* such as logos, backgrounds, scenery or other non-animated elements. Images can have input
* events and physics bodies, or be tweened, tinted or scrolled. The main difference between an
* Image and a Sprite is that you cannot animate an Image as they do not have the Animation component.
*
* @class ImpactImage
* @extends Phaser.GameObjects.Image
* @memberOf Phaser.Physics.Impact
* @constructor
* @since 3.0.0
*
* @extends Phaser.Physics.Impact.Components.Acceleration
* @extends Phaser.Physics.Impact.Components.BodyScale
* @extends Phaser.Physics.Impact.Components.BodyType
* @extends Phaser.Physics.Impact.Components.Bounce
* @extends Phaser.Physics.Impact.Components.CheckAgainst
* @extends Phaser.Physics.Impact.Components.Collides
* @extends Phaser.Physics.Impact.Components.Debug
* @extends Phaser.Physics.Impact.Components.Friction
* @extends Phaser.Physics.Impact.Components.Gravity
* @extends Phaser.Physics.Impact.Components.Offset
* @extends Phaser.Physics.Impact.Components.SetGameObject
* @extends Phaser.Physics.Impact.Components.Velocity
* @extends Phaser.GameObjects.Components.Alpha
* @extends Phaser.GameObjects.Components.BlendMode
* @extends Phaser.GameObjects.Components.Depth
* @extends Phaser.GameObjects.Components.Flip
* @extends Phaser.GameObjects.Components.GetBounds
* @extends Phaser.GameObjects.Components.Origin
* @extends Phaser.GameObjects.Components.Pipeline
* @extends Phaser.GameObjects.Components.ScaleMode
* @extends Phaser.GameObjects.Components.ScrollFactor
* @extends Phaser.GameObjects.Components.Size
* @extends Phaser.GameObjects.Components.Texture
* @extends Phaser.GameObjects.Components.Tint
* @extends Phaser.GameObjects.Components.Transform
* @extends Phaser.GameObjects.Components.Visible
*
* @param {Phaser.Physics.Impact.World} world - [description]
* @param {number} x - The horizontal position of this Game Object in the world.
* @param {number} y - The vertical position of this Game Object in the world.
* @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
* @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with.
*/
var ImpactImage = new Class({
Extends: Image,
@ -24,22 +71,74 @@ var ImpactImage = new Class({
initialize:
// x/y is the center of the Image / Body, just like other default Game Objects
function ImpactImage (world, x, y, texture, frame)
{
Image.call(this, world.scene, x, y, texture, frame);
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactImage#body
* @type {Phaser.Physics.Impact.Body}
* @since 3.0.0
*/
this.body = world.create(x - this.frame.centerX, y - this.frame.centerY, this.width, this.height);
this.body.parent = this;
this.body.gameObject = this;
// Local references to the Body properties
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactImage#size
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.size = this.body.size;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactImage#offset
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.offset = this.body.offset;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactImage#vel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.vel = this.body.vel;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactImage#accel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.accel = this.body.accel;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactImage#friction
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.friction = this.body.friction;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactImage#maxVel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.maxVel = this.body.maxVel;
}

View file

@ -5,17 +5,39 @@ var Merge = require('../../utils/object/Merge');
var PluginManager = require('../../plugins/PluginManager');
var World = require('./World');
// Phaser.Physics.Impact.ImpactPhysics
/**
* @classdesc
* [description]
*
* @class ImpactPhysics
* @memberOf Phaser.Physics.Impact
* @constructor
* @since 3.0.0
*
* @param {Phaser.Scene} scene - [description]
*/
var ImpactPhysics = new Class({
initialize:
function ImpactPhysics (scene)
{
// The Scene that owns this plugin
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactPhysics#scene
* @type {Phaser.Scene}
* @since 3.0.0
*/
this.scene = scene;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactPhysics#systems
* @type {Phaser.Scenes.Systems}
* @since 3.0.0
*/
this.systems = scene.sys;
if (!scene.sys.settings.isBooted)
@ -23,13 +45,42 @@ var ImpactPhysics = new Class({
scene.sys.events.once('boot', this.boot, this);
}
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactPhysics#config
* @type {object}
* @since 3.0.0
*/
this.config = this.getConfig();
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactPhysics#world
* @type {Phaser.Physics.Impact.World}
* @since 3.0.0
*/
this.world;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactPhysics#add
* @type {Phaser.Physics.Impact.Factory}
* @since 3.0.0
*/
this.add;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.ImpactPhysics#getConfig
* @since 3.0.0
*
* @return {object} [description]
*/
getConfig: function ()
{
var gameConfig = this.systems.game.config.physics;
@ -43,6 +94,12 @@ var ImpactPhysics = new Class({
return config;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.ImpactPhysics#boot
* @since 3.0.0
*/
boot: function ()
{
this.world = new World(this.scene, this.config);
@ -55,11 +112,49 @@ var ImpactPhysics = new Class({
eventEmitter.on('destroy', this.destroy, this);
},
/**
* [description]
*
* @method Phaser.Physics.Impact.ImpactPhysics#pause
* @since 3.0.0
*
* @return {[type]} [description]
*/
pause: function ()
{
return this.world.pause();
},
/**
* [description]
*
* @method Phaser.Physics.Impact.ImpactPhysics#resume
* @since 3.0.0
*
* @return {[type]} [description]
*/
resume: function ()
{
return this.world.resume();
},
/**
* [description]
*
* @method Phaser.Physics.Impact.ImpactPhysics#shutdown
* @since 3.0.0
*/
shutdown: function ()
{
this.world.shutdown();
},
/**
* [description]
*
* @method Phaser.Physics.Impact.ImpactPhysics#destroy
* @since 3.0.0
*/
destroy: function ()
{
this.world.destroy();

View file

@ -1,8 +1,59 @@
var Class = require('../../utils/Class');
var Components = require('./components');
var Sprite = require('../../gameobjects/sprite/Sprite');
/**
* @classdesc
* An Impact Physics Sprite Game Object.
*
* A Sprite Game Object is used for the display of both static and animated images in your game.
* Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled
* and animated.
*
* The main difference between a Sprite and an Image Game Object is that you cannot animate Images.
* As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation
* Component. If you do not require animation then you can safely use Images to replace Sprites in all cases.
*
* @class ImpactSprite
* @extends Phaser.GameObjects.Sprite
* @memberOf Phaser.Physics.Impact
* @constructor
* @since 3.0.0
*
* @extends Phaser.Physics.Impact.Components.Acceleration
* @extends Phaser.Physics.Impact.Components.BodyScale
* @extends Phaser.Physics.Impact.Components.BodyType
* @extends Phaser.Physics.Impact.Components.Bounce
* @extends Phaser.Physics.Impact.Components.CheckAgainst
* @extends Phaser.Physics.Impact.Components.Collides
* @extends Phaser.Physics.Impact.Components.Debug
* @extends Phaser.Physics.Impact.Components.Friction
* @extends Phaser.Physics.Impact.Components.Gravity
* @extends Phaser.Physics.Impact.Components.Offset
* @extends Phaser.Physics.Impact.Components.SetGameObject
* @extends Phaser.Physics.Impact.Components.Velocity
* @extends Phaser.GameObjects.Components.Alpha
* @extends Phaser.GameObjects.Components.Animation
* @extends Phaser.GameObjects.Components.BlendMode
* @extends Phaser.GameObjects.Components.Depth
* @extends Phaser.GameObjects.Components.Flip
* @extends Phaser.GameObjects.Components.GetBounds
* @extends Phaser.GameObjects.Components.Origin
* @extends Phaser.GameObjects.Components.Pipeline
* @extends Phaser.GameObjects.Components.ScaleMode
* @extends Phaser.GameObjects.Components.ScrollFactor
* @extends Phaser.GameObjects.Components.Size
* @extends Phaser.GameObjects.Components.Texture
* @extends Phaser.GameObjects.Components.Tint
* @extends Phaser.GameObjects.Components.Transform
* @extends Phaser.GameObjects.Components.Visible
*
* @param {Phaser.Physics.Impact.World} world - [description]
* @param {number} x - The horizontal position of this Game Object in the world.
* @param {number} y - The vertical position of this Game Object in the world.
* @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
* @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with.
*/
var ImpactSprite = new Class({
Extends: Sprite,
@ -24,22 +75,74 @@ var ImpactSprite = new Class({
initialize:
// x/y is the center of the Sprite / Body, just like other default Game Objects
function ImpactSprite (world, x, y, texture, frame)
{
Sprite.call(this, world.scene, x, y, texture, frame);
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#body
* @type {Phaser.Physics.Impact.Body}
* @since 3.0.0
*/
this.body = world.create(x - this.frame.centerX, y - this.frame.centerY, this.width, this.height);
this.body.parent = this;
this.body.gameObject = this;
// Local references to the Body properties
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#size
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.size = this.body.size;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#offset
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.offset = this.body.offset;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#vel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.vel = this.body.vel;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#accel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.accel = this.body.accel;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#friction
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.friction = this.body.friction;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#maxVel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.maxVel = this.body.maxVel;
}

View file

@ -1,9 +1,17 @@
var COLLIDES = require('./COLLIDES');
var SeperateX = require('./SeperateX');
var SeperateY = require('./SeperateY');
var COLLIDES = require('./COLLIDES');
// Impact Physics Solver
/**
* Impact Physics Solver
*
* @function Phaser.Physics.Impact.Solver
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.World} world - [description]
* @param {Phaser.Physics.Impact.Body} bodyA - [description]
* @param {Phaser.Physics.Impact.Body} bodyB - [description]
*/
var Solver = function (world, bodyA, bodyB)
{
var weak = null;

View file

@ -1,10 +1,17 @@
// Set up the trace-result
// var res = {
// collision: {x: false, y: false, slope: false},
// pos: {x: x, y: y},
// tile: {x: 0, y: 0}
// };
/**
* Set up the trace-result
* var res = {
* collision: {x: false, y: false, slope: false},
* pos: {x: x, y: y},
* tile: {x: 0, y: 0}
* };
*
* @function Phaser.Physics.Impact.UpdateMotion
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body} body - [description]
* @param {object} res - [description]
*/
var UpdateMotion = function (body, res)
{
body.standing = false;

View file

@ -1,18 +1,28 @@
// Phaser.Physics.Impact.World
var Body = require('./Body');
var Class = require('../../utils/Class');
var COLLIDES = require('./COLLIDES');
var CollisionMap = require('./CollisionMap');
var EventEmitter = require('eventemitter3');
var GetFastValue = require('../../utils/object/GetFastValue');
var HasValue = require('../../utils/object/HasValue');
var Set = require('../../structs/Set');
var Solver = require('./Solver');
var TYPE = require('./TYPE');
var TILEMAP_FORMATS = require('../../tilemaps/Formats');
var HasValue = require('../../utils/object/HasValue');
var GetFastValue = require('../../utils/object/GetFastValue');
var TYPE = require('./TYPE');
/**
* @classdesc
* [description]
*
* @class World
* @extends Phaser.Physics.Impact.EventEmitter
* @memberOf Phaser.Physics.Impact
* @constructor
* @since 3.0.0
*
* @param {Phaser.Scene} scene - [description]
* @param {object} config - [description]
*/
var World = new Class({
Extends: EventEmitter,
@ -23,30 +33,110 @@ var World = new Class({
{
EventEmitter.call(this);
/**
* [description]
*
* @name Phaser.Physics.Impact.World#scene
* @type {Phaser.Scene}
* @since 3.0.0
*/
this.scene = scene;
/**
* [description]
*
* @name Phaser.Physics.Impact.World#bodies
* @type {Phaser.Structs.Set}
* @since 3.0.0
*/
this.bodies = new Set();
/**
* [description]
*
* @name Phaser.Physics.Impact.World#gravity
* @type {number}
* @default 0
* @since 3.0.0
*/
this.gravity = GetFastValue(config, 'gravity', 0);
// Spatial hash cell dimensions
/**
* Spatial hash cell dimensions
*
* @name Phaser.Physics.Impact.World#cellSize
* @type {integer}
* @default 64
* @since 3.0.0
*/
this.cellSize = GetFastValue(config, 'cellSize', 64);
/**
* [description]
*
* @name Phaser.Physics.Impact.World#collisionMap
* @type {Phaser.Physics.Impact.CollisionMap}
* @since 3.0.0
*/
this.collisionMap = new CollisionMap();
/**
* [description]
*
* @name Phaser.Physics.Impact.World#timeScale
* @type {float}
* @default 1
* @since 3.0.0
*/
this.timeScale = GetFastValue(config, 'timeScale', 1);
// Impacts maximum time step is 20 fps.
/**
* Impacts maximum time step is 20 fps.
*
* @name Phaser.Physics.Impact.World#maxStep
* @type {number}
* @default 0.05
* @since 3.0.0
*/
this.maxStep = GetFastValue(config, 'maxStep', 0.05);
/**
* [description]
*
* @name Phaser.Physics.Impact.World#enabled
* @type {boolean}
* @default true
* @since 3.0.0
*/
this.enabled = true;
/**
* [description]
*
* @name Phaser.Physics.Impact.World#drawDebug
* @type {boolean}
* @since 3.0.0
*/
this.drawDebug = GetFastValue(config, 'debug', false);
/**
* [description]
*
* @name Phaser.Physics.Impact.World#debugGraphic
* @type {Phaser.GameObjects.Graphics}
* @since 3.0.0
*/
this.debugGraphic;
var _maxVelocity = GetFastValue(config, 'maxVelocity', 100);
/**
* [description]
*
* @name Phaser.Physics.Impact.World#defaults
* @type {object}
* @since 3.0.0
*/
this.defaults = {
debugShowBody: GetFastValue(config, 'debugShowBody', true),
debugShowVelocity: GetFastValue(config, 'debugShowVelocity', true),
@ -60,12 +150,33 @@ var World = new Class({
};
/**
* @property {object} walls - An object containing the 4 wall bodies that bound the physics world.
* An object containing the 4 wall bodies that bound the physics world.
*
* @name Phaser.Physics.Impact.World#walls
* @type {object}
* @since 3.0.0
*/
this.walls = { left: null, right: null, top: null, bottom: null };
/**
* [description]
*
* @name Phaser.Physics.Impact.World#delta
* @type {number}
* @default 0
* @since 3.0.0
*/
this.delta = 0;
/**
* [description]
*
* @name Phaser.Physics.Impact.World#_lastId
* @type {number}
* @private
* @default 0
* @since 3.0.0
*/
this._lastId = 0;
if (GetFastValue(config, 'setBounds', false))
@ -102,10 +213,14 @@ var World = new Class({
* Sets the collision map for the world either from a Weltmeister JSON level in the cache or from
* a 2D array. If loading from a Weltmeister level, the map must have a layer called "collision".
*
* @method Phaser.Physics.Impact.World#setCollisionMap
* @since 3.0.0
*
* @param {string|integer[][]} key - Either a string key that corresponds to a Weltmeister level
* in the cache, or a 2D array of collision IDs.
* @param {integer} tileSize - The size of a tile. This is optional if loading from a Weltmeister
* level in the cache.
*
* @return {CollisionMap|null} The newly created CollisionMap, or null if the method failed to
* create the CollisionMap.
*/
@ -154,6 +269,9 @@ var World = new Class({
* ways. The easiest is to use Tiled and the slopeTileProperty option. Alternatively, you can
* manually create a slopeMap that stores the mapping between tile indices and slope IDs.
*
* @method Phaser.Physics.Impact.World#setCollisionMapFromTilemapLayer
* @since 3.0.0
*
* @param {StaticTilemapLayer|DynamicTilemapLayer} tilemapLayer - The tilemap layer to use.
* @param {object} [options] - Options for controlling the mapping from tiles to slope IDs.
* @param {string} [options.slopeTileProperty=null] - Slope IDs can be stored on tiles directly
@ -165,7 +283,8 @@ var World = new Class({
* assign to a colliding tile. If not specified, the tile's index is used.
* @param {integer} [options.defaultNonCollidingSlope=0] - The default slope ID to assign to a
* non-colliding tile.
* @return {CollisionMap} The newly created CollisionMap.
*
* @return {Phaser.Physics.Impact.CollisionMap} The newly created CollisionMap.
*/
setCollisionMapFromTilemapLayer: function (tilemapLayer, options)
{
@ -226,15 +345,20 @@ var World = new Class({
* the newly created bounds will also not have the left and right walls.
* Explicitly state them in the parameters to override this.
*
* @method Phaser.Physics.P2#setBounds
* @param {number} x - The x coordinate of the top-left corner of the bounds.
* @param {number} y - The y coordinate of the top-left corner of the bounds.
* @param {number} width - The width of the bounds.
* @param {number} height - The height of the bounds.
* @method Phaser.Physics.Impact.World#setBounds
* @since 3.0.0
*
* @param {number} [x] - The x coordinate of the top-left corner of the bounds.
* @param {number} [y] - The y coordinate of the top-left corner of the bounds.
* @param {number} [width] - The width of the bounds.
* @param {number} [height] - The height of the bounds.
* @param {number} [thickness=64] - [description]
* @param {boolean} [left=true] - If true will create the left bounds wall.
* @param {boolean} [right=true] - If true will create the right bounds wall.
* @param {boolean} [top=true] - If true will create the top bounds wall.
* @param {boolean} [bottom=true] - If true will create the bottom bounds wall.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setBounds: function (x, y, width, height, thickness, left, right, top, bottom)
{
@ -256,7 +380,19 @@ var World = new Class({
return this;
},
// position = 'left', 'right', 'top' or 'bottom'
/**
* position = 'left', 'right', 'top' or 'bottom'
*
* @method Phaser.Physics.Impact.World#updateWall
* @since 3.0.0
*
* @param {boolean} add - [description]
* @param {string} position - [description]
* @param {number} x - [description]
* @param {number} y - [description]
* @param {number} width - [description]
* @param {number} height - [description]
*/
updateWall: function (add, position, x, y, width, height)
{
var wall = this.walls[position];
@ -286,11 +422,19 @@ var World = new Class({
}
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#createDebugGraphic
* @since 3.0.0
*
* @return {Phaser.GameObjects.Graphics} [description]
*/
createDebugGraphic: function ()
{
var graphic = this.scene.sys.add.graphics({ x: 0, y: 0 });
graphic.setZ(Number.MAX_VALUE);
graphic.setDepth(Number.MAX_VALUE);
this.debugGraphic = graphic;
@ -299,11 +443,32 @@ var World = new Class({
return graphic;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#getNextID
* @since 3.0.0
*
* @return {integer} [description]
*/
getNextID: function ()
{
return this._lastId++;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#create
* @since 3.0.0
*
* @param {number} x - [description]
* @param {number} y - [description]
* @param {number} sizeX - [description]
* @param {number} sizeY - [description]
*
* @return {Phaser.Physics.Impact.Body} The Body that was added to this World.
*/
create: function (x, y, sizeX, sizeY)
{
var body = new Body(this, x, y, sizeX, sizeY);
@ -313,25 +478,62 @@ var World = new Class({
return body;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#remove
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body} object - The Body to remove from this World.
*/
remove: function (object)
{
this.bodies.delete(object);
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#pause
* @since 3.0.0
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
pause: function ()
{
this.enabled = false;
this.emit('pause');
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#resume
* @since 3.0.0
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
resume: function ()
{
this.enabled = true;
this.emit('resume');
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#update
* @since 3.0.0
*
* @param {number} time - [description]
* @param {number} delta - [description]
*/
update: function (time, delta)
{
if (!this.enabled || this.bodies.size === 0)
@ -394,7 +596,16 @@ var World = new Class({
}
},
// Check the body against the spatial hash
/**
* Check the body against the spatial hash.
*
* @method Phaser.Physics.Impact.World#checkHash
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body} body - [description]
* @param {object} hash - [description]
* @param {number} size - [description]
*/
checkHash: function (body, hash, size)
{
var checked = {};
@ -437,6 +648,15 @@ var World = new Class({
}
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#checkBodies
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body} bodyA - [description]
* @param {Phaser.Physics.Impact.Body} bodyB - [description]
*/
checkBodies: function (bodyA, bodyB)
{
// 2 fixed bodies won't do anything
@ -462,10 +682,16 @@ var World = new Class({
}
},
// ////////////
// Helpers //
// ////////////
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setCollidesNever
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the collides value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setCollidesNever: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
@ -476,6 +702,16 @@ var World = new Class({
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setLite
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the collides value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setLite: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
@ -486,6 +722,16 @@ var World = new Class({
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setPassive
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the collides value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setPassive: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
@ -496,6 +742,16 @@ var World = new Class({
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setActive
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the collides value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setActive: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
@ -506,6 +762,16 @@ var World = new Class({
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setFixed
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the collides value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setFixed: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
@ -516,6 +782,16 @@ var World = new Class({
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setTypeNone
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setTypeNone: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
@ -526,6 +802,16 @@ var World = new Class({
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setTypeA
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setTypeA: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
@ -536,6 +822,16 @@ var World = new Class({
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setTypeB
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setTypeB: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
@ -546,6 +842,16 @@ var World = new Class({
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setAvsB
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setAvsB: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
@ -557,6 +863,16 @@ var World = new Class({
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setBvsA
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setBvsA: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
@ -568,6 +884,16 @@ var World = new Class({
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setCheckAgainstNone
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setCheckAgainstNone: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
@ -578,6 +904,16 @@ var World = new Class({
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setCheckAgainstA
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setCheckAgainstA: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
@ -588,6 +924,16 @@ var World = new Class({
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#setCheckAgainstB
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on.
*
* @return {Phaser.Physics.Impact.World} This World object.
*/
setCheckAgainstB: function (bodies)
{
for (var i = 0; i < bodies.length; i++)
@ -598,11 +944,23 @@ var World = new Class({
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#shutdown
* @since 3.0.0
*/
shutdown: function ()
{
this.removeAllListeners();
},
/**
* [description]
*
* @method Phaser.Physics.Impact.World#destroy
* @since 3.0.0
*/
destroy: function ()
{
this.removeAllListeners();

View file

@ -1,38 +1,212 @@
var Class = require('../../utils/Class');
var Utils = require('./Utils');
/**
* @classdesc
* [description]
*
* @class WebGLPipeline
* @memberOf Phaser.Renderer.WebGL
* @constructor
* @since 3.0.0
*
* @param {object} config - [description]
*/
var WebGLPipeline = new Class({
initialize:
function WebGLPipeline (config)
{
/**
* [description]
*
* @name Phaser.Renderer.WebGL.WebGLPipeline#name
* @type {string}
* @since 3.0.0
*/
this.name = 'WebGLPipeline';
/**
* [description]
*
* @name Phaser.Renderer.WebGL.WebGLPipeline#game
* @type {Phaser.Game}
* @since 3.0.0
*/
this.game = config.game;
/**
* [description]
*
* @name Phaser.Renderer.WebGL.WebGLPipeline#view
* @type {HTMLCanvasElement}
* @since 3.0.0
*/
this.view = config.game.canvas;
/**
* [description]
*
* @name Phaser.Renderer.WebGL.WebGLPipeline#resolution
* @type {number}
* @since 3.0.0
*/
this.resolution = config.game.config.resolution;
/**
* [description]
*
* @name Phaser.Renderer.WebGL.WebGLPipeline#width
* @type {number}
* @since 3.0.0
*/
this.width = config.game.config.width * this.resolution;
/**
* [description]
*
* @name Phaser.Renderer.WebGL.WebGLPipeline#height
* @type {number}
* @since 3.0.0
*/
this.height = config.game.config.height * this.resolution;
/**
* [description]
*
* @name Phaser.Renderer.WebGL.WebGLPipeline#gl
* @type {[type]}
* @since 3.0.0
*/
this.gl = config.gl;
/**
* [description]
*
* @name Phaser.Renderer.WebGL.WebGLPipeline#vertexCount
* @type {number}
* @default 0
* @since 3.0.0
*/
this.vertexCount = 0;
/**
* [description]
*
* @name Phaser.Renderer.WebGL.WebGLPipeline#vertexCapacity
* @type {integer}
* @since 3.0.0
*/
this.vertexCapacity = config.vertexCapacity;
/**
* [description]
*
* @name Phaser.Renderer.WebGL.WebGLPipeline#renderer
* @type {Phaser.Renderer.WebGL.WebGLRenderer}
* @since 3.0.0
*/
this.renderer = config.renderer;
/**
* [description]
*
* @name Phaser.Renderer.WebGL.WebGLPipeline#vertexData
* @type {[type]}
* @since 3.0.0
*/
this.vertexData = (config.vertices ? config.vertices : new ArrayBuffer(config.vertexCapacity * config.vertexSize));
/**
* [description]
*
* @name Phaser.Renderer.WebGL.WebGLPipeline#vertexBuffer
* @type {[type]}
* @since 3.0.0
*/
this.vertexBuffer = this.renderer.createVertexBuffer((config.vertices ? config.vertices : this.vertexData.byteLength), this.gl.STREAM_DRAW);
/**
* [description]
*
* @name Phaser.Renderer.WebGL.WebGLPipeline#program
* @type {[type]}
* @since 3.0.0
*/
this.program = this.renderer.createProgram(config.vertShader, config.fragShader);
/**
* [description]
*
* @name Phaser.Renderer.WebGL.WebGLPipeline#attributes
* @type {[type]}
* @since 3.0.0
*/
this.attributes = config.attributes;
/**
* [description]
*
* @name Phaser.Renderer.WebGL.WebGLPipeline#vertexSize
* @type {[type]}
* @since 3.0.0
*/
this.vertexSize = config.vertexSize;
/**
* [description]
*
* @name Phaser.Renderer.WebGL.WebGLPipeline#topology
* @type {[type]}
* @since 3.0.0
*/
this.topology = config.topology;
/**
* [description]
*
* @name Phaser.Renderer.WebGL.WebGLPipeline#bytes
* @type {Uint8Array}
* @since 3.0.0
*/
this.bytes = new Uint8Array(this.vertexData);
// This will store the amount of components of 32 bit length
/**
* This will store the amount of components of 32 bit length
*
* @name Phaser.Renderer.WebGL.WebGLPipeline#vertexComponentCount
* @type {[type]}
* @since 3.0.0
*/
this.vertexComponentCount = Utils.getComponentCount(config.attributes);
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.WebGLPipeline#shouldFlush
* @since 3.0.0
*
* @return {boolean} [description]
*/
shouldFlush: function ()
{
return this.vertexCount >= this.vertexCapacity;
return (this.vertexCount >= this.vertexCapacity);
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.WebGLPipeline#resize
* @since 3.0.0
*
* @param {number} width - [description]
* @param {number} height - [description]
* @param {number} resolution - [description]
*
* @return {Phaser.Renderer.WebGL.WebGLPipeline} [description]
*/
resize: function (width, height, resolution)
{
this.width = width * resolution;
@ -40,6 +214,14 @@ var WebGLPipeline = new Class({
return this;
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.WebGLPipeline#bind
* @since 3.0.0
*
* @return {Phaser.Renderer.WebGL.WebGLPipeline} [description]
*/
bind: function ()
{
var gl = this.gl;
@ -71,30 +253,73 @@ var WebGLPipeline = new Class({
return this;
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.WebGLPipeline#onBind
* @since 3.0.0
*
* @return {Phaser.Renderer.WebGL.WebGLPipeline} [description]
*/
onBind: function ()
{
// This is for updating uniform data it's called on each bind attempt.
return this;
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.WebGLPipeline#onPreRender
* @since 3.0.0
*
* @return {Phaser.Renderer.WebGL.WebGLPipeline} [description]
*/
onPreRender: function ()
{
// called once every frame
return this;
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.WebGLPipeline#onRender
* @since 3.0.0
*
* @param {Phaser.Scene} scene - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*
* @return {Phaser.Renderer.WebGL.WebGLPipeline} [description]
*/
onRender: function (scene, camera)
{
// called for each camera
return this;
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.WebGLPipeline#onPostRender
* @since 3.0.0
*
* @return {Phaser.Renderer.WebGL.WebGLPipeline} [description]
*/
onPostRender: function ()
{
// called once every frame
return this;
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.WebGLPipeline#flush
* @since 3.0.0
*
* @return {Phaser.Renderer.WebGL.WebGLPipeline} [description]
*/
flush: function ()
{
var gl = this.gl;
@ -114,6 +339,14 @@ var WebGLPipeline = new Class({
return this;
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.WebGLPipeline#destroy
* @since 3.0.0
*
* @return {Phaser.Renderer.WebGL.WebGLPipeline} [description]
*/
destroy: function ()
{
var gl = this.gl;

File diff suppressed because it is too large Load diff

View file

@ -1,9 +1,23 @@
var Class = require('../../../utils/Class');
var WebGLPipeline = require('../WebGLPipeline');
var Utils = require('../Utils');
var ShaderSourceVS = require('../shaders/BitmapMask.vert');
var ShaderSourceFS = require('../shaders/BitmapMask.frag');
var ShaderSourceVS = require('../shaders/BitmapMask.vert');
var Utils = require('../Utils');
var WebGLPipeline = require('../WebGLPipeline');
/**
* @classdesc
* [description]
*
* @class BitmapMaskPipeline
* @extends Phaser.Renderer.WebGL.WebGLPipeline
* @memberOf Phaser.Renderer.WebGL
* @constructor
* @since 3.0.0
*
* @param {Phaser.Game} game - [description]
* @param {[type]} gl - [description]
* @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - [description]
*/
var BitmapMaskPipeline = new Class({
Extends: WebGLPipeline,
@ -39,11 +53,44 @@ var BitmapMaskPipeline = new Class({
]
});
/**
* [description]
*
* @name Phaser.Renderer.WebGL.BitmapMaskPipeline#vertexViewF32
* @type {Float32Array}
* @since 3.0.0
*/
this.vertexViewF32 = new Float32Array(this.vertexData);
/**
* [description]
*
* @name Phaser.Renderer.WebGL.BitmapMaskPipeline#maxQuads
* @type {number}
* @default 1
* @since 3.0.0
*/
this.maxQuads = 1;
/**
* [description]
*
* @name Phaser.Renderer.WebGL.BitmapMaskPipeline#resolutionDirty
* @type {boolean}
* @default true
* @since 3.0.0
*/
this.resolutionDirty = true;
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.BitmapMaskPipeline#onBind
* @since 3.0.0
*
* @return {Phaser.Renderer.WebGL.BitmapMaskPipeline} [description]
*/
onBind: function ()
{
WebGLPipeline.prototype.onBind.call(this);
@ -62,6 +109,18 @@ var BitmapMaskPipeline = new Class({
return this;
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.BitmapMaskPipeline#resize
* @since 3.0.0
*
* @param {number} width - [description]
* @param {number} height - [description]
* @param {number} resolution - [description]
*
* @return {Phaser.Renderer.WebGL.BitmapMaskPipeline} [description]
*/
resize: function (width, height, resolution)
{
WebGLPipeline.prototype.resize.call(this, width, height, resolution);
@ -69,6 +128,16 @@ var BitmapMaskPipeline = new Class({
return this;
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.BitmapMaskPipeline#beginMask
* @since 3.0.0
*
* @param {[type]} mask - [description]
* @param {[type]} maskedObject - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*/
beginMask: function (mask, maskedObject, camera)
{
var bitmapMask = mask.bitmapMask;
@ -96,6 +165,14 @@ var BitmapMaskPipeline = new Class({
}
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.BitmapMaskPipeline#endMask
* @since 3.0.0
*
* @param {[type]} mask - [description]
*/
endMask: function (mask)
{
var bitmapMask = mask.bitmapMask;

View file

@ -1,11 +1,11 @@
var Class = require('../../../utils/Class');
var WebGLPipeline = require('../WebGLPipeline');
var Utils = require('../Utils');
var Earcut = require('../../../geom/polygon/Earcut');
var ShaderSourceVS = require('../shaders/FlatTint.vert');
var ShaderSourceFS = require('../shaders/FlatTint.frag');
var Commands = require('../../../gameobjects/graphics/Commands');
var Earcut = require('../../../geom/polygon/Earcut');
var ModelViewProjection = require('./components/ModelViewProjection');
var ShaderSourceFS = require('../shaders/FlatTint.frag');
var ShaderSourceVS = require('../shaders/FlatTint.vert');
var Utils = require('../Utils');
var WebGLPipeline = require('../WebGLPipeline');
var Point = function (x, y, width, rgb, alpha)
{
@ -28,6 +28,20 @@ var matrixStack = new Float32Array(6 * 1000);
var matrixStackLength = 0;
var pathArray = [];
/**
* @classdesc
* [description]
*
* @class FlatTintPipeline
* @extends Phaser.Renderer.WebGL.WebGLPipeline
* @memberOf Phaser.Renderer.WebGL
* @constructor
* @since 3.0.0
*
* @param {Phaser.Game} game - [description]
* @param {[type]} gl - [description]
* @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - [description]
*/
var FlatTintPipeline = new Class({
Extends: WebGLPipeline,
@ -71,18 +85,59 @@ var FlatTintPipeline = new Class({
]
});
/**
* [description]
*
* @name Phaser.Renderer.WebGL.FlatTintPipeline#vertexViewF32
* @type {Float32Array}
* @since 3.0.0
*/
this.vertexViewF32 = new Float32Array(this.vertexData);
/**
* [description]
*
* @name Phaser.Renderer.WebGL.FlatTintPipeline#vertexViewU32
* @type {Uint32Array}
* @since 3.0.0
*/
this.vertexViewU32 = new Uint32Array(this.vertexData);
/**
* [description]
*
* @name Phaser.Renderer.WebGL.FlatTintPipeline#tempTriangle
* @type {array}
* @since 3.0.0
*/
this.tempTriangle = [
{x: 0, y: 0, width: 0, rgb: 0xFFFFFF, alpha: 1.0},
{x: 0, y: 0, width: 0, rgb: 0xFFFFFF, alpha: 1.0},
{x: 0, y: 0, width: 0, rgb: 0xFFFFFF, alpha: 1.0},
{x: 0, y: 0, width: 0, rgb: 0xFFFFFF, alpha: 1.0}
];
/**
* [description]
*
* @name Phaser.Renderer.WebGL.FlatTintPipeline#polygonCache
* @type {array}
* @default []
* @since 3.0.0
*/
this.polygonCache = [];
this.mvpInit();
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.FlatTintPipeline#onBind
* @since 3.0.0
*
* @return {Phaser.Renderer.WebGL.FlatTintPipeline} [description]
*/
onBind: function ()
{
WebGLPipeline.prototype.onBind.call(this);
@ -91,6 +146,18 @@ var FlatTintPipeline = new Class({
return this;
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.FlatTintPipeline#resize
* @since 3.0.0
*
* @param {number} width - [description]
* @param {number} height - [description]
* @param {number} resolution - [description]
*
* @return {Phaser.Renderer.WebGL.FlatTintPipeline} [description]
*/
resize: function (width, height, resolution)
{
WebGLPipeline.prototype.resize.call(this, width, height, resolution);
@ -99,6 +166,32 @@ var FlatTintPipeline = new Class({
return this;
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.FlatTintPipeline#batchFillRect
* @since 3.0.0
*
* @param {[type]} srcX - [description]
* @param {[type]} srcY - [description]
* @param {[type]} srcScaleX - [description]
* @param {[type]} srcScaleY - [description]
* @param {[type]} srcRotation - [description]
* @param {[type]} x - [description]
* @param {[type]} y - [description]
* @param {[type]} width - [description]
* @param {[type]} height - [description]
* @param {[type]} fillColor - [description]
* @param {[type]} fillAlpha - [description]
* @param {[type]} a1 - [description]
* @param {[type]} b1 - [description]
* @param {[type]} c1 - [description]
* @param {[type]} d1 - [description]
* @param {[type]} e1 - [description]
* @param {[type]} f1 - [description]
* @param {[type]} currentMatrix - [description]
* @param {[type]} roundPixels - [description]
*/
batchFillRect: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, x, y, width, height, fillColor, fillAlpha, a1, b1, c1, d1, e1, f1, currentMatrix, roundPixels)
{
this.renderer.setPipeline(this);
@ -171,6 +264,34 @@ var FlatTintPipeline = new Class({
this.vertexCount += 6;
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.FlatTintPipeline#batchFillTriangle
* @since 3.0.0
*
* @param {[type]} srcX - [description]
* @param {[type]} srcY - [description]
* @param {[type]} srcScaleX - [description]
* @param {[type]} srcScaleY - [description]
* @param {[type]} srcRotation - [description]
* @param {[type]} x0 - [description]
* @param {[type]} y0 - [description]
* @param {[type]} x1 - [description]
* @param {[type]} y1 - [description]
* @param {[type]} x2 - [description]
* @param {[type]} y2 - [description]
* @param {[type]} fillColor - [description]
* @param {[type]} fillAlpha - [description]
* @param {[type]} a1 - [description]
* @param {[type]} b1 - [description]
* @param {[type]} c1 - [description]
* @param {[type]} d1 - [description]
* @param {[type]} e1 - [description]
* @param {[type]} f1 - [description]
* @param {[type]} currentMatrix - [description]
* @param {[type]} roundPixels - [description]
*/
batchFillTriangle: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, x0, y0, x1, y1, x2, y2, fillColor, fillAlpha, a1, b1, c1, d1, e1, f1, currentMatrix, roundPixels)
{
this.renderer.setPipeline(this);
@ -228,9 +349,37 @@ var FlatTintPipeline = new Class({
this.vertexCount += 3;
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.FlatTintPipeline#batchStrokeTriangle
* @since 3.0.0
*
* @param {[type]} srcX - [description]
* @param {[type]} srcY - [description]
* @param {[type]} srcScaleX - [description]
* @param {[type]} srcScaleY - [description]
* @param {[type]} srcRotation - [description]
* @param {[type]} x0 - [description]
* @param {[type]} y0 - [description]
* @param {[type]} x1 - [description]
* @param {[type]} y1 - [description]
* @param {[type]} x2 - [description]
* @param {[type]} y2 - [description]
* @param {[type]} lineWidth - [description]
* @param {[type]} lineColor - [description]
* @param {[type]} lineAlpha - [description]
* @param {[type]} a - [description]
* @param {[type]} b - [description]
* @param {[type]} c - [description]
* @param {[type]} d - [description]
* @param {[type]} e - [description]
* @param {[type]} f - [description]
* @param {[type]} currentMatrix - [description]
* @param {[type]} roundPixels - [description]
*/
batchStrokeTriangle: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, x0, y0, x1, y1, x2, y2, lineWidth, lineColor, lineAlpha, a, b, c, d, e, f, currentMatrix, roundPixels)
{
var tempTriangle = this.tempTriangle;
tempTriangle[0].x = x0;
@ -264,6 +413,29 @@ var FlatTintPipeline = new Class({
);
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.FlatTintPipeline#batchFillPath
* @since 3.0.0
*
* @param {[type]} srcX - [description]
* @param {[type]} srcY - [description]
* @param {[type]} srcScaleX - [description]
* @param {[type]} srcScaleY - [description]
* @param {[type]} srcRotation - [description]
* @param {[type]} path - [description]
* @param {[type]} fillColor - [description]
* @param {[type]} fillAlpha - [description]
* @param {[type]} a1 - [description]
* @param {[type]} b1 - [description]
* @param {[type]} c1 - [description]
* @param {[type]} d1 - [description]
* @param {[type]} e1 - [description]
* @param {[type]} f1 - [description]
* @param {[type]} currentMatrix - [description]
* @param {[type]} roundPixels - [description]
*/
batchFillPath: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, path, fillColor, fillAlpha, a1, b1, c1, d1, e1, f1, currentMatrix, roundPixels)
{
this.renderer.setPipeline(this);
@ -356,6 +528,31 @@ var FlatTintPipeline = new Class({
polygonCache.length = 0;
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.FlatTintPipeline#batchStrokePath
* @since 3.0.0
*
* @param {[type]} srcX - [description]
* @param {[type]} srcY - [description]
* @param {[type]} srcScaleX - [description]
* @param {[type]} srcScaleY - [description]
* @param {[type]} srcRotation - [description]
* @param {[type]} path - [description]
* @param {[type]} lineWidth - [description]
* @param {[type]} lineColor - [description]
* @param {[type]} lineAlpha - [description]
* @param {[type]} a - [description]
* @param {[type]} b - [description]
* @param {[type]} c - [description]
* @param {[type]} d - [description]
* @param {[type]} e - [description]
* @param {[type]} f - [description]
* @param {[type]} isLastPath - [description]
* @param {[type]} currentMatrix - [description]
* @param {[type]} roundPixels - [description]
*/
batchStrokePath: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, path, lineWidth, lineColor, lineAlpha, a, b, c, d, e, f, isLastPath, currentMatrix, roundPixels)
{
this.renderer.setPipeline(this);
@ -424,9 +621,37 @@ var FlatTintPipeline = new Class({
}
polylines.length = 0;
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.FlatTintPipeline#batchLine
* @since 3.0.0
*
* @param {[type]} srcX - [description]
* @param {[type]} srcY - [description]
* @param {[type]} srcScaleX - [description]
* @param {[type]} srcScaleY - [description]
* @param {[type]} srcRotation - [description]
* @param {[type]} ax - [description]
* @param {[type]} ay - [description]
* @param {[type]} bx - [description]
* @param {[type]} by - [description]
* @param {[type]} aLineWidth - [description]
* @param {[type]} bLineWidth - [description]
* @param {[type]} aLineColor - [description]
* @param {[type]} bLineColor - [description]
* @param {[type]} lineAlpha - [description]
* @param {[type]} a1 - [description]
* @param {[type]} b1 - [description]
* @param {[type]} c1 - [description]
* @param {[type]} d1 - [description]
* @param {[type]} e1 - [description]
* @param {[type]} f1 - [description]
* @param {[type]} currentMatrix - [description]
* @param {[type]} roundPixels - [description]
*/
batchLine: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, ax, ay, bx, by, aLineWidth, bLineWidth, aLineColor, bLineColor, lineAlpha, a1, b1, c1, d1, e1, f1, currentMatrix, roundPixels)
{
this.renderer.setPipeline(this);
@ -521,6 +746,15 @@ var FlatTintPipeline = new Class({
];
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.FlatTintPipeline#batchGraphics
* @since 3.0.0
*
* @param {Phaser.GameObjects.Graphics} graphics - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*/
batchGraphics: function (graphics, camera)
{
if (graphics.commandBuffer.length <= 0) return;
@ -877,42 +1111,132 @@ var FlatTintPipeline = new Class({
// Stubs
/**
* [description]
*
* @method Phaser.Renderer.WebGL.FlatTintPipeline#drawStaticTilemapLayer
* @since 3.0.0
*
* @param {[type]} tilemap - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*/
drawStaticTilemapLayer: function (tilemap, camera)
{
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.FlatTintPipeline#drawEmitterManager
* @since 3.0.0
*
* @param {[type]} emitterManager - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*/
drawEmitterManager: function (emitterManager, camera)
{
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.FlatTintPipeline#drawBlitter
* @since 3.0.0
*
* @param {[type]} blitter - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*/
drawBlitter: function (blitter, camera)
{
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.FlatTintPipeline#batchSprite
* @since 3.0.0
*
* @param {[type]} sprite - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*/
batchSprite: function (sprite, camera)
{
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.FlatTintPipeline#batchMesh
* @since 3.0.0
*
* @param {[type]} mesh - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*/
batchMesh: function (mesh, camera)
{
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.FlatTintPipeline#batchBitmapText
* @since 3.0.0
*
* @param {[type]} bitmapText - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*/
batchBitmapText: function (bitmapText, camera)
{
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.FlatTintPipeline#batchDynamicBitmapText
* @since 3.0.0
*
* @param {[type]} bitmapText - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*/
batchDynamicBitmapText: function (bitmapText, camera)
{
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.FlatTintPipeline#batchText
* @since 3.0.0
*
* @param {[type]} text - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*/
batchText: function (text, camera)
{
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.FlatTintPipeline#batchDynamicTilemapLayer
* @since 3.0.0
*
* @param {[type]} tilemapLayer - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*/
batchDynamicTilemapLayer: function (tilemapLayer, camera)
{
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.FlatTintPipeline#batchTileSprite
* @since 3.0.0
*
* @param {[type]} tileSprite - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*/
batchTileSprite: function (tileSprite, camera)
{
}

View file

@ -1,11 +1,25 @@
var Class = require('../../../utils/Class');
var WebGLPipeline = require('../WebGLPipeline');
var Utils = require('../Utils');
var TextureTintPipeline = require('./TextureTintPipeline');
var ShaderSourceFS = require('../shaders/ForwardDiffuse.frag');
var TextureTintPipeline = require('./TextureTintPipeline');
var Utils = require('../Utils');
var WebGLPipeline = require('../WebGLPipeline');
var LIGHT_COUNT = 10;
/**
* @classdesc
* [description]
*
* @class ForwardDiffuseLightPipeline
* @extends Phaser.Renderer.WebGL.TextureTintPipeline
* @memberOf Phaser.Renderer.WebGL
* @constructor
* @since 3.0.0
*
* @param {Phaser.Game} game - [description]
* @param {[type]} gl - [description]
* @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - [description]
*/
var ForwardDiffuseLightPipeline = new Class({
Extends: TextureTintPipeline,
@ -17,6 +31,14 @@ var ForwardDiffuseLightPipeline = new Class({
TextureTintPipeline.call(this, game, gl, renderer, ShaderSourceFS.replace('%LIGHT_COUNT%', LIGHT_COUNT.toString()));
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#onBind
* @since 3.0.0
*
* @return {Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline} [description]
*/
onBind: function ()
{
TextureTintPipeline.prototype.onBind.call(this);
@ -32,6 +54,17 @@ var ForwardDiffuseLightPipeline = new Class({
return this;
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#onRender
* @since 3.0.0
*
* @param {Phaser.Scene} scene - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*
* @return {Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline} [description]
*/
onRender: function (scene, camera)
{
var lightManager = scene.lights;
@ -75,6 +108,17 @@ var ForwardDiffuseLightPipeline = new Class({
return this;
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#drawStaticTilemapLayer
* @since 3.0.0
*
* @param {[type]} tilemap - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*
* @return {[type]} [description]
*/
drawStaticTilemapLayer: function (tilemap, camera)
{
var normalTexture = tilemap.texture.dataSource[0];
@ -90,6 +134,17 @@ var ForwardDiffuseLightPipeline = new Class({
}
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#drawEmitterManager
* @since 3.0.0
*
* @param {[type]} emitterManager - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*
* @return {[type]} [description]
*/
drawEmitterManager: function (emitterManager, camera)
{
var normalTexture = emitterManager.texture.dataSource[0];
@ -105,6 +160,17 @@ var ForwardDiffuseLightPipeline = new Class({
}
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#drawBlitter
* @since 3.0.0
*
* @param {Phaser.GameObjects.Blitter} blitter - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*
* @return {[type]} [description]
*/
drawBlitter: function (blitter, camera)
{
var normalTexture = blitter.texture.dataSource[0];
@ -120,6 +186,17 @@ var ForwardDiffuseLightPipeline = new Class({
}
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchSprite
* @since 3.0.0
*
* @param {Phaser.GameObjects.Sprite} sprite - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*
* @return {[type]} [description]
*/
batchSprite: function (sprite, camera)
{
var normalTexture = sprite.texture.dataSource[0];
@ -136,6 +213,17 @@ var ForwardDiffuseLightPipeline = new Class({
}
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchMesh
* @since 3.0.0
*
* @param {Phaser.GameObjects.Mesh} mesh - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*
* @return {[type]} [description]
*/
batchMesh: function (mesh, camera)
{
var normalTexture = mesh.texture.dataSource[0];
@ -153,6 +241,17 @@ var ForwardDiffuseLightPipeline = new Class({
}
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchBitmapText
* @since 3.0.0
*
* @param {[type]} bitmapText - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*
* @return {[type]} [description]
*/
batchBitmapText: function (bitmapText, camera)
{
var normalTexture = bitmapText.texture.dataSource[0];
@ -168,6 +267,17 @@ var ForwardDiffuseLightPipeline = new Class({
}
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchDynamicBitmapText
* @since 3.0.0
*
* @param {[type]} bitmapText - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*
* @return {[type]} [description]
*/
batchDynamicBitmapText: function (bitmapText, camera)
{
var normalTexture = bitmapText.texture.dataSource[0];
@ -183,6 +293,17 @@ var ForwardDiffuseLightPipeline = new Class({
}
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchText
* @since 3.0.0
*
* @param {[type]} text - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*
* @return {[type]} [description]
*/
batchText: function (text, camera)
{
var normalTexture = text.texture.dataSource[0];
@ -198,6 +319,17 @@ var ForwardDiffuseLightPipeline = new Class({
}
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchDynamicTilemapLayer
* @since 3.0.0
*
* @param {[type]} tilemapLayer - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*
* @return {[type]} [description]
*/
batchDynamicTilemapLayer: function (tilemapLayer, camera)
{
var normalTexture = tilemapLayer.texture.dataSource[0];
@ -213,6 +345,17 @@ var ForwardDiffuseLightPipeline = new Class({
}
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchTileSprite
* @since 3.0.0
*
* @param {Phaser.GameObjects.TileSprite} tileSprite - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*
* @return {[type]} [description]
*/
batchTileSprite: function (tileSprite, camera)
{
var normalTexture = tileSprite.texture.dataSource[0];

View file

@ -1,10 +1,25 @@
var Class = require('../../../utils/Class');
var WebGLPipeline = require('../WebGLPipeline');
var Utils = require('../Utils');
var ShaderSourceVS = require('../shaders/TextureTint.vert');
var ShaderSourceFS = require('../shaders/TextureTint.frag');
var ModelViewProjection = require('./components/ModelViewProjection');
var ShaderSourceFS = require('../shaders/TextureTint.frag');
var ShaderSourceVS = require('../shaders/TextureTint.vert');
var Utils = require('../Utils');
var WebGLPipeline = require('../WebGLPipeline');
/**
* @classdesc
* [description]
*
* @class TextureTintPipeline
* @extends Phaser.Renderer.WebGL.WebGLPipeline
* @memberOf Phaser.Renderer.WebGL
* @constructor
* @since 3.0.0
*
* @param {Phaser.Game} game - [description]
* @param {[type]} gl - [description]
* @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - [description]
* @param {boolean} overrideFragmentShader - [description]
*/
var TextureTintPipeline = new Class({
Extends: WebGLPipeline,
@ -56,12 +71,45 @@ var TextureTintPipeline = new Class({
]
});
/**
* [description]
*
* @name Phaser.Renderer.WebGL.TextureTintPipeline#vertexViewF32
* @type {Float32Array}
* @since 3.0.0
*/
this.vertexViewF32 = new Float32Array(this.vertexData);
/**
* [description]
*
* @name Phaser.Renderer.WebGL.TextureTintPipeline#vertexViewU32
* @type {Uint32Array}
* @since 3.0.0
*/
this.vertexViewU32 = new Uint32Array(this.vertexData);
/**
* [description]
*
* @name Phaser.Renderer.WebGL.TextureTintPipeline#maxQuads
* @type {integer}
* @default 2000
* @since 3.0.0
*/
this.maxQuads = 2000;
this.mvpInit();
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.TextureTintPipeline#onBind
* @since 3.0.0
*
* @return {Phaser.Renderer.WebGL.TextureTintPipeline} [description]
*/
onBind: function ()
{
WebGLPipeline.prototype.onBind.call(this);
@ -70,14 +118,34 @@ var TextureTintPipeline = new Class({
return this;
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.TextureTintPipeline#resize
* @since 3.0.0
*
* @param {number} width - [description]
* @param {number} height - [description]
* @param {number} resolution - [description]
*
* @return {Phaser.Renderer.WebGL.TextureTintPipeline} [description]
*/
resize: function (width, height, resolution)
{
WebGLPipeline.prototype.resize.call(this, width, height, resolution);
this.projOrtho(0, this.width, this.height, 0, -1000.0, 1000.0);
return this;
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.TextureTintPipeline#drawStaticTilemapLayer
* @since 3.0.0
*
* @param {[type]} tilemap - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*/
drawStaticTilemapLayer: function (tilemap, camera)
{
if (tilemap.vertexCount > 0)
@ -107,6 +175,15 @@ var TextureTintPipeline = new Class({
this.modelIdentity();
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.TextureTintPipeline#drawEmitterManager
* @since 3.0.0
*
* @param {[type]} emitterManager - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*/
drawEmitterManager: function (emitterManager, camera)
{
this.renderer.setPipeline(this);
@ -262,6 +339,15 @@ var TextureTintPipeline = new Class({
}
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.TextureTintPipeline#drawBlitter
* @since 3.0.0
*
* @param {Phaser.GameObjects.Blitter} blitter - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*/
drawBlitter: function (blitter, camera)
{
this.renderer.setPipeline(this);
@ -377,6 +463,15 @@ var TextureTintPipeline = new Class({
}
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.TextureTintPipeline#batchSprite
* @since 3.0.0
*
* @param {Phaser.GameObjects.Sprite} sprite - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*/
batchSprite: function (sprite, camera)
{
this.renderer.setPipeline(this);
@ -502,6 +597,15 @@ var TextureTintPipeline = new Class({
this.vertexCount += 6;
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.TextureTintPipeline#batchMesh
* @since 3.0.0
*
* @param {Phaser.GameObjects.Mesh} mesh - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*/
batchMesh: function (mesh, camera)
{
var vertices = mesh.vertices;
@ -589,6 +693,15 @@ var TextureTintPipeline = new Class({
this.vertexCount += vertexCount;
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.TextureTintPipeline#batchBitmapText
* @since 3.0.0
*
* @param {[type]} bitmapText - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*/
batchBitmapText: function (bitmapText, camera)
{
this.renderer.setPipeline(this);
@ -803,6 +916,15 @@ var TextureTintPipeline = new Class({
}
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.TextureTintPipeline#batchDynamicBitmapText
* @since 3.0.0
*
* @param {[type]} bitmapText - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*/
batchDynamicBitmapText: function (bitmapText, camera)
{
this.renderer.setPipeline(this);
@ -1094,6 +1216,15 @@ var TextureTintPipeline = new Class({
}
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.TextureTintPipeline#batchText
* @since 3.0.0
*
* @param {[type]} text - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*/
batchText: function (text, camera)
{
var getTint = Utils.getTintAppendFloatAlpha;
@ -1119,6 +1250,15 @@ var TextureTintPipeline = new Class({
);
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.TextureTintPipeline#batchDynamicTilemapLayer
* @since 3.0.0
*
* @param {[type]} tilemapLayer - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*/
batchDynamicTilemapLayer: function (tilemapLayer, camera)
{
var renderTiles = tilemapLayer.culledTiles;
@ -1166,6 +1306,15 @@ var TextureTintPipeline = new Class({
}
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.TextureTintPipeline#batchTileSprite
* @since 3.0.0
*
* @param {Phaser.GameObjects.TileSprite} tileSprite - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*/
batchTileSprite: function (tileSprite, camera)
{
var getTint = Utils.getTintAppendFloatAlpha;
@ -1192,6 +1341,41 @@ var TextureTintPipeline = new Class({
);
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.TextureTintPipeline#batchTexture
* @since 3.0.0
*
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
* @param {[type]} texture - [description]
* @param {[type]} textureWidth - [description]
* @param {[type]} textureHeight - [description]
* @param {[type]} srcX - [description]
* @param {[type]} srcY - [description]
* @param {[type]} srcWidth - [description]
* @param {[type]} srcHeight - [description]
* @param {[type]} scaleX - [description]
* @param {[type]} scaleY - [description]
* @param {[type]} rotation - [description]
* @param {[type]} flipX - [description]
* @param {[type]} flipY - [description]
* @param {[type]} scrollFactorX - [description]
* @param {[type]} scrollFactorY - [description]
* @param {[type]} displayOriginX - [description]
* @param {[type]} displayOriginY - [description]
* @param {[type]} frameX - [description]
* @param {[type]} frameY - [description]
* @param {[type]} frameWidth - [description]
* @param {[type]} frameHeight - [description]
* @param {[type]} tintTL - [description]
* @param {[type]} tintTR - [description]
* @param {[type]} tintBL - [description]
* @param {[type]} tintBR - [description]
* @param {[type]} uOffset - [description]
* @param {[type]} vOffset - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*/
batchTexture: function (
gameObject,
texture,
@ -1317,6 +1501,15 @@ var TextureTintPipeline = new Class({
this.vertexCount += 6;
},
/**
* [description]
*
* @method Phaser.Renderer.WebGL.TextureTintPipeline#batchGraphics
* @since 3.0.0
*
* @param {[type]} graphics - [description]
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
*/
batchGraphics: function (graphics, camera)
{
// Stub

View file

@ -1,15 +1,94 @@
module.exports = {
/**
* Scene state.
*
* @name Phaser.Scenes.PENDING
* @type {integer}
* @since 3.0.0
*/
PENDING: 0,
/**
* Scene state.
*
* @name Phaser.Scenes.INIT
* @type {integer}
* @since 3.0.0
*/
INIT: 1,
/**
* Scene state.
*
* @name Phaser.Scenes.START
* @type {integer}
* @since 3.0.0
*/
START: 2,
/**
* Scene state.
*
* @name Phaser.Scenes.LOADING
* @type {integer}
* @since 3.0.0
*/
LOADING: 3,
/**
* Scene state.
*
* @name Phaser.Scenes.CREATING
* @type {integer}
* @since 3.0.0
*/
CREATING: 4,
/**
* Scene state.
*
* @name Phaser.Scenes.RUNNING
* @type {integer}
* @since 3.0.0
*/
RUNNING: 5,
/**
* Scene state.
*
* @name Phaser.Scenes.PAUSED
* @type {integer}
* @since 3.0.0
*/
PAUSED: 6,
/**
* Scene state.
*
* @name Phaser.Scenes.SLEEPING
* @type {integer}
* @since 3.0.0
*/
SLEEPING: 7,
/**
* Scene state.
*
* @name Phaser.Scenes.SHUTDOWN
* @type {integer}
* @since 3.0.0
*/
SHUTDOWN: 8,
/**
* Scene state.
*
* @name Phaser.Scenes.DESTROYED
* @type {integer}
* @since 3.0.0
*/
DESTROYED: 9
};

View file

@ -5,6 +5,7 @@
module.exports = {
Components: require('./components/'),
Parsers: require('./parsers'),
Formats: require('./Formats'),
ImageCollection: require('./ImageCollection'),

View file

@ -1,8 +1,8 @@
var Formats = require('../Formats');
var Parse2DArray = require('./Parse2DArray');
var ParseCSV = require('./ParseCSV');
var ParseTiledJSON = require('./parsetiledjson/');
var ParseWeltmister = require('./parseweltmeister/');
var Formats = require('../Formats');
var ParseTiledJSON = require('./tiled/');
var ParseWeltmister = require('./impact/');
/**
* Parses raw data of a given Tilemap format into a new MapData object. If no recognized data format

View file

@ -1,6 +1,6 @@
var MapData = require('../mapdata/MapData');
var LayerData = require('../mapdata/LayerData');
var Formats = require('../Formats');
var LayerData = require('../mapdata/LayerData');
var MapData = require('../mapdata/MapData');
var Tile = require('../Tile');
/**

View file

@ -0,0 +1,14 @@
/**
* @namespace Phaser.Tilemaps.Parsers
*/
module.exports = {
Parse: require('./Parse'),
Parse2DArray: require('./Parse2DArray'),
ParseCSV: require('./ParseCSV'),
Impact: require('./impact'),
Tiled: require('./tiled')
};

View file

@ -1,4 +1,3 @@
var Pick = require('./Pick');
var ParseGID = require('./ParseGID');

View file

@ -1,12 +1,24 @@
var HasValue = require('../../../utils/object/HasValue');
var pick = function (object, keys)
/**
* [description]
*
* @function Phaser.Tilemaps.Parsers.Tiled.Pick
* @since 3.0.0
*
* @param {[type]} object - [description]
* @param {[type]} keys - [description]
*
* @return {[type]} [description]
*/
var Pick = function (object, keys)
{
var obj = {};
for (var i = 0; i < keys.length; i++)
{
var key = keys[i];
if (HasValue(object, key))
{
obj[key] = object[key];
@ -16,4 +28,4 @@ var pick = function (object, keys)
return obj;
};
module.exports = pick;
module.exports = Pick;

View file

@ -1,26 +1,158 @@
var TWEEN_CONST = {
// TweenData:
/**
* TweenData state.
*
* @name Phaser.Tweens.CREATED
* @type {integer}
* @since 3.0.0
*/
CREATED: 0,
/**
* TweenData state.
*
* @name Phaser.Tweens.INIT
* @type {integer}
* @since 3.0.0
*/
INIT: 1,
/**
* TweenData state.
*
* @name Phaser.Tweens.OFFSET_DELAY
* @type {integer}
* @since 3.0.0
*/
DELAY: 2,
/**
* TweenData state.
*
* @name Phaser.Tweens.OFFSET_DELAY
* @type {integer}
* @since 3.0.0
*/
OFFSET_DELAY: 3,
/**
* TweenData state.
*
* @name Phaser.Tweens.PLAYING_FORWARD
* @type {integer}
* @since 3.0.0
*/
PENDING_RENDER: 4,
/**
* TweenData state.
*
* @name Phaser.Tweens.PLAYING_FORWARD
* @type {integer}
* @since 3.0.0
*/
PLAYING_FORWARD: 5,
/**
* TweenData state.
*
* @name Phaser.Tweens.PLAYING_BACKWARD
* @type {integer}
* @since 3.0.0
*/
PLAYING_BACKWARD: 6,
/**
* TweenData state.
*
* @name Phaser.Tweens.HOLD_DELAY
* @type {integer}
* @since 3.0.0
*/
HOLD_DELAY: 7,
/**
* TweenData state.
*
* @name Phaser.Tweens.REPEAT_DELAY
* @type {integer}
* @since 3.0.0
*/
REPEAT_DELAY: 8,
/**
* TweenData state.
*
* @name Phaser.Tweens.COMPLETE
* @type {integer}
* @since 3.0.0
*/
COMPLETE: 9,
// Tween specific (starts from 20 to cleanly allow extra TweenData consts in the future)
/**
* Tween state.
*
* @name Phaser.Tweens.PENDING_ADD
* @type {integer}
* @since 3.0.0
*/
PENDING_ADD: 20,
/**
* Tween state.
*
* @name Phaser.Tweens.LOOP_DELAY
* @type {integer}
* @since 3.0.0
*/
PAUSED: 21,
/**
* Tween state.
*
* @name Phaser.Tweens.LOOP_DELAY
* @type {integer}
* @since 3.0.0
*/
LOOP_DELAY: 22,
/**
* Tween state.
*
* @name Phaser.Tweens.ACTIVE
* @type {integer}
* @since 3.0.0
*/
ACTIVE: 23,
/**
* Tween state.
*
* @name Phaser.Tweens.COMPLETE_DELAY
* @type {integer}
* @since 3.0.0
*/
COMPLETE_DELAY: 24,
/**
* Tween state.
*
* @name Phaser.Tweens.PENDING_REMOVE
* @type {integer}
* @since 3.0.0
*/
PENDING_REMOVE: 25,
/**
* Tween state.
*
* @name Phaser.Tweens.REMOVED
* @type {integer}
* @since 3.0.0
*/
REMOVED: 26
};