mirror of
https://github.com/photonstorm/phaser
synced 2024-11-26 14:40:38 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
a0e462dd46
671 changed files with 13732 additions and 9075 deletions
|
@ -9,7 +9,8 @@
|
|||
"WEBGL_RENDERER": true,
|
||||
"CANVAS_RENDERER": true,
|
||||
"Phaser": true,
|
||||
"p2": true
|
||||
"p2": true,
|
||||
"ActiveXObject": true
|
||||
},
|
||||
"rules": {
|
||||
|
||||
|
|
|
@ -34,8 +34,8 @@ var PlaceOnTriangle = function (items, triangle, stepRate)
|
|||
var item = items[i];
|
||||
var point = p1[Math.floor(p)];
|
||||
|
||||
item.x = point[0];
|
||||
item.y = point[1];
|
||||
item.x = point.x;
|
||||
item.y = point.y;
|
||||
|
||||
p += step;
|
||||
}
|
||||
|
|
|
@ -462,8 +462,6 @@ var Animation = new Class({
|
|||
});
|
||||
}
|
||||
|
||||
// console.table(frames);
|
||||
|
||||
if (!Array.isArray(frames) || frames.length === 0)
|
||||
{
|
||||
return out;
|
||||
|
@ -480,8 +478,10 @@ var Animation = new Class({
|
|||
continue;
|
||||
}
|
||||
|
||||
// Could be an integer or a string
|
||||
var frame = GetValue(item, 'frame', 0);
|
||||
|
||||
// The actual texture frame
|
||||
var textureFrame = textureManager.getFrame(key, frame);
|
||||
|
||||
animationFrame = new Frame(key, frame, index, textureFrame);
|
||||
|
@ -489,14 +489,6 @@ var Animation = new Class({
|
|||
animationFrame.duration = GetValue(item, 'duration', 0);
|
||||
animationFrame.onUpdate = GetValue(item, 'onUpdate', null);
|
||||
|
||||
var visible = GetValue(item, 'visible', null);
|
||||
|
||||
if (visible !== null)
|
||||
{
|
||||
animationFrame.setVisible = true;
|
||||
animationFrame.visible = visible;
|
||||
}
|
||||
|
||||
animationFrame.isFirst = (!prev);
|
||||
|
||||
// The previously created animationFrame
|
||||
|
|
|
@ -1,156 +1,156 @@
|
|||
var Class = require('../utils/Class');
|
||||
|
||||
// Phaser.Animations.AnimationFrame
|
||||
|
||||
var AnimationFrame = new Class({
|
||||
|
||||
initialize:
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A single frame in an Animation sequence.
|
||||
*
|
||||
* An AnimationFrame consists of a reference to the Texture it uses for rendering, references to other
|
||||
* frames in the animation, and index data. It also has the ability to fire its own `onUpdate` callback
|
||||
* and modify the animation timing.
|
||||
*
|
||||
* AnimationFrames are generated automatically by the Animation class.
|
||||
*
|
||||
* @class AnimationFrame
|
||||
* @memberOf Phaser.Animations.AnimationFrame
|
||||
* @memberOf Phaser.Animations
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {undefined} textureKey - [description]
|
||||
* @param {undefined} textureFrame - [description]
|
||||
* @param {undefined} index - [description]
|
||||
* @param {undefined} frame - [description]
|
||||
* @param {string} textureKey - The key of the Texture this AnimationFrame uses.
|
||||
* @param {string|integer} textureFrame - The key of the Frame within the Texture that this AnimationFrame uses.
|
||||
* @param {integer} index - The index of this AnimationFrame within the Animation sequence.
|
||||
* @param {Phaser.Textures.Frame} frame - A reference to the Texture Frame this AnimationFrame uses for rendering.
|
||||
*/
|
||||
function AnimationFrame (textureKey, textureFrame, index, frame)
|
||||
{
|
||||
// The keys into the Texture Manager of the texture + frame this uses
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The key of the Texture this AnimationFrame uses.
|
||||
*
|
||||
* @property {string} textureKey
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.textureKey = textureKey;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The key of the Frame within the Texture that this AnimationFrame uses.
|
||||
*
|
||||
* @property {Phaser.Textures.Frame} textureFrame
|
||||
* @property {string|integer} textureFrame
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.textureFrame = textureFrame;
|
||||
|
||||
// The index of this frame within the Animation.frames array
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The index of this AnimationFrame within the Animation sequence.
|
||||
*
|
||||
* @property {integer} index
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.index = index;
|
||||
|
||||
// Texture Frame
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A reference to the Texture Frame this AnimationFrame uses for rendering.
|
||||
*
|
||||
* @property {Phaser.Textures.Frame} frame
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.frame = frame;
|
||||
|
||||
// Read-only
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Is this the first frame in an animation sequence?
|
||||
*
|
||||
* @property {boolean} isFirst
|
||||
* @default false
|
||||
* @readOnly
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.isFirst = false;
|
||||
|
||||
// Read-only
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Is this the last frame in an animation sequence?
|
||||
*
|
||||
* @property {boolean} isLast
|
||||
* @default false
|
||||
* @readOnly
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.isLast = false;
|
||||
|
||||
// The frame that comes before this one in the animation (if any)
|
||||
// Read-only
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A reference to the AnimationFrame that comes before this one in the animation, if any.
|
||||
*
|
||||
* @property {?[type]} prevFrame
|
||||
* @property {?Phaser.Animations.AnimationFrame} prevFrame
|
||||
* @default null
|
||||
* @readOnly
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.prevFrame = null;
|
||||
|
||||
// The frame that comes after this one in the animation (if any)
|
||||
// Read-only
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A reference to the AnimationFrame that comes after this one in the animation, if any.
|
||||
*
|
||||
* @property {?[type]} nextFrame
|
||||
* @property {?Phaser.Animations.AnimationFrame} nextFrame
|
||||
* @default null
|
||||
* @readOnly
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.nextFrame = null;
|
||||
|
||||
// Additional time (in ms) this frame should appear for - added onto the msPerFrame
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Additional time (in ms) that this frame should appear for during playback.
|
||||
* The value is added onto the msPerFrame set by the animation.
|
||||
*
|
||||
* @property {number} duration
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.duration = 0;
|
||||
|
||||
// What % through the animation progress is this frame?
|
||||
// Read-only
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* What % through the animation does this frame come?
|
||||
* This value is generated when the animation is created and cached here.
|
||||
*
|
||||
* @property {number} progress
|
||||
* @default 0
|
||||
* @readOnly
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.progress = 0;
|
||||
|
||||
// Callback if this frame gets displayed
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A frame specific callback, invoked if this frame gets displayed and the callback is set.
|
||||
*
|
||||
* @property {?[type]} onUpdate
|
||||
* @property {?function} onUpdate
|
||||
* @default null
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.onUpdate = null;
|
||||
|
||||
// When this frame hits, set sprite.visible to this
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {boolean} setVisible
|
||||
* @default false
|
||||
*/
|
||||
this.setVisible = false;
|
||||
|
||||
this.visible = false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Generates a JavaScript object suitable for converting to JSON.
|
||||
*
|
||||
* @method Phaser.Animations.AnimationFrame#toJSON
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {object} The AnimationFrame data.
|
||||
*/
|
||||
toJSON: function ()
|
||||
{
|
||||
return {
|
||||
key: this.textureKey,
|
||||
frame: this.textureFrame,
|
||||
duration: this.duration,
|
||||
visible: this.visible
|
||||
duration: this.duration
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroys this object by removing references to external resources and callbacks.
|
||||
*
|
||||
* @method Phaser.Animations.AnimationFrame#destroy
|
||||
* @since 3.0.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
this.frame = undefined;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
var Class = require('../utils/Class');
|
||||
var CONST = require('../const');
|
||||
var DefaultScenePlugins = require('../DefaultScenePlugins');
|
||||
var DefaultScenePlugins = require('../plugins/DefaultScenePlugins');
|
||||
var GetValue = require('../utils/object/GetValue');
|
||||
var MATH = require('../math/const');
|
||||
var NOOP = require('../utils/NOOP');
|
||||
|
@ -23,9 +23,22 @@ var ValueToColor = require('../display/color/ValueToColor');
|
|||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} GameConfig
|
||||
* @typedef {object} LoaderConfig
|
||||
*
|
||||
* @todo Add Physics Config
|
||||
* @property {string} [baseURL] - [description]
|
||||
* @property {string} [path] - [description]
|
||||
* @property {boolean} [enableParallel=true] - [description]
|
||||
* @property {integer} [maxParallelDownloads=4] - [description]
|
||||
* @property {string|undefined} [crossOrigin=undefined] - [description]
|
||||
* @property {string} [responseType] - [description]
|
||||
* @property {boolean} [async=true] - [description]
|
||||
* @property {string} [user] - [description]
|
||||
* @property {string} [password] - [description]
|
||||
* @property {integer} [timeout=0] - [description]
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} GameConfig
|
||||
*
|
||||
* @property {integer|string} [width=1024] - [description]
|
||||
* @property {integer|string} [height=768] - [description]
|
||||
|
@ -59,11 +72,10 @@ var ValueToColor = require('../display/color/ValueToColor');
|
|||
* @property {boolean} [transparent=false] - [description]
|
||||
* @property {boolean} [clearBeforeRender=true] - [description]
|
||||
* @property {string|number} [backgroundColor=0x000000] - [description]
|
||||
* @property {boolean} [preserveDrawingBuffer=false] - [description]
|
||||
* @property {object} [?callbacks] - [description]
|
||||
* @property {function} [callbacks.preBoot=NOOP] - [description]
|
||||
* @property {function} [callbacks.postBoot=NOOP] - [description]
|
||||
* @property {boolean} [useTicker=false] - [description]
|
||||
* @property {LoaderConfig} [?loader] - [description]
|
||||
* @property {object} [?images] - [description]
|
||||
* @property {string} [images.default] - [description]
|
||||
* @property {string} [images.missing] - [description]
|
||||
|
@ -164,14 +176,11 @@ var Config = new Class({
|
|||
this.transparent = GetValue(config, 'transparent', false);
|
||||
this.clearBeforeRender = GetValue(config, 'clearBeforeRender', true);
|
||||
this.backgroundColor = ValueToColor(GetValue(config, 'backgroundColor', 0));
|
||||
this.preserveDrawingBuffer = GetValue(config, 'preserveDrawingBuffer', false);
|
||||
|
||||
// Callbacks
|
||||
this.preBoot = GetValue(config, 'callbacks.preBoot', NOOP);
|
||||
this.postBoot = GetValue(config, 'callbacks.postBoot', NOOP);
|
||||
|
||||
this.useTicker = GetValue(config, 'useTicker', false);
|
||||
|
||||
// Physics
|
||||
// physics: {
|
||||
// system: 'impact',
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
var CONST = require('../const');
|
||||
var CanvasPool = require('../display/canvas/CanvasPool');
|
||||
var Features = require('../device/Features');
|
||||
var CanvasInterpolation = require('../display/canvas/CanvasInterpolation');
|
||||
var CanvasPool = require('../display/canvas/CanvasPool');
|
||||
var CONST = require('../const');
|
||||
var Features = require('../device/Features');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Called automatically by Phaser.Game and responsible for creating the renderer it will use.
|
||||
*
|
||||
* Relies upon two webpack global flags to be defined: `WEBGL_RENDERER` and `CANVAS_RENDERER` during build time, but not at run-time.
|
||||
*
|
||||
* @function Phaser.Boot.CreateRenderer
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Game} game - [description]
|
||||
* @param {Phaser.Game} game - The Phaser.Game instance on which the renderer will be set.
|
||||
*/
|
||||
var CreateRenderer = function (game)
|
||||
{
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
var CONST = require('../const');
|
||||
var CHECKSUM = require('../checksum');
|
||||
var CONST = require('../const');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Called automatically by Phaser.Game and responsible for creating the console.log debug header.
|
||||
*
|
||||
* You can customize or disable the header via the Game Config object.
|
||||
*
|
||||
* @function Phaser.Boot.DebugHeader
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Game} game - [description]
|
||||
* @param {Phaser.Game} game - The Phaser.Game instance which will output this debug header.
|
||||
*/
|
||||
var DebugHeader = function (game)
|
||||
{
|
||||
|
@ -21,15 +23,15 @@ var DebugHeader = function (game)
|
|||
var renderType = (config.renderType === CONST.CANVAS) ? 'Canvas' : 'WebGL';
|
||||
|
||||
var audioConfig = config.audio;
|
||||
var deviceAudio = game.device.Audio;
|
||||
var deviceAudio = game.device.audio;
|
||||
|
||||
var audioType;
|
||||
|
||||
if(deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio))
|
||||
if (deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio))
|
||||
{
|
||||
audioType = 'Web Audio';
|
||||
}
|
||||
else if((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData))
|
||||
else if ((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData))
|
||||
{
|
||||
audioType = 'No Audio';
|
||||
}
|
||||
|
@ -38,9 +40,7 @@ var DebugHeader = function (game)
|
|||
audioType = 'HTML5 Audio';
|
||||
}
|
||||
|
||||
var ie = false;
|
||||
|
||||
if (!ie)
|
||||
if (!game.device.browser.ie)
|
||||
{
|
||||
var c = '';
|
||||
var args = [ c ];
|
||||
|
@ -103,9 +103,6 @@ var DebugHeader = function (game)
|
|||
{
|
||||
console.log('Phaser v' + CONST.VERSION + ' / http://phaser.io');
|
||||
}
|
||||
|
||||
// Keep this during dev build only
|
||||
// console.log(CHECKSUM.build);
|
||||
};
|
||||
|
||||
module.exports = DebugHeader;
|
||||
|
|
199
src/boot/Game.js
199
src/boot/Game.js
|
@ -1,31 +1,35 @@
|
|||
var Class = require('../utils/Class');
|
||||
var Config = require('./Config');
|
||||
var DebugHeader = require('./DebugHeader');
|
||||
var Device = require('../device');
|
||||
var NOOP = require('../utils/NOOP');
|
||||
|
||||
var AddToDOM = require('../dom/AddToDOM');
|
||||
var DOMContentLoaded = require('../dom/DOMContentLoaded');
|
||||
var EventEmitter = require('eventemitter3');
|
||||
var VisibilityHandler = require('./VisibilityHandler');
|
||||
|
||||
var AnimationManager = require('../animations/AnimationManager');
|
||||
var CacheManager = require('../cache/CacheManager');
|
||||
var Class = require('../utils/Class');
|
||||
var Config = require('./Config');
|
||||
var CreateRenderer = require('./CreateRenderer');
|
||||
var Data = require('../data/Data');
|
||||
var DebugHeader = require('./DebugHeader');
|
||||
var Device = require('../device');
|
||||
var DOMContentLoaded = require('../dom/DOMContentLoaded');
|
||||
var EventEmitter = require('eventemitter3');
|
||||
var InputManager = require('../input/InputManager');
|
||||
var NOOP = require('../utils/NOOP');
|
||||
var PluginManager = require('../plugins/PluginManager');
|
||||
var SceneManager = require('../scene/SceneManager');
|
||||
var SoundManagerCreator = require('../sound/SoundManagerCreator');
|
||||
var TextureManager = require('../textures/TextureManager');
|
||||
var TimeStep = require('./TimeStep');
|
||||
var VisibilityHandler = require('./VisibilityHandler');
|
||||
|
||||
var Game = new Class({
|
||||
|
||||
initialize:
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The Phaser.Game instance is the main controller for the entire Phaser game. It is responsible
|
||||
* for handling the boot process, parsing the configuration values, creating the renderer,
|
||||
* and setting-up all of the global Phaser systems, such as sound and input.
|
||||
* Once that is complete it will start the Scene Manager and then begin the main game loop.
|
||||
*
|
||||
* You should generally avoid accessing any of the systems created by Game, and instead use those
|
||||
* made available to you via the Phaser.Scene Systems class instead.
|
||||
*
|
||||
* @class Game
|
||||
* @memberOf Phaser
|
||||
|
@ -37,128 +41,172 @@ var Game = new Class({
|
|||
function Game (config)
|
||||
{
|
||||
/**
|
||||
* [description]
|
||||
* The parsed Game Configuration object.
|
||||
* The values stored within this object are read-only and should not be changed at run-time.
|
||||
*
|
||||
* @property {Phaser.Boot.Config} config
|
||||
* @readOnly
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.config = new Config(config);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A reference to either the Canvas or WebGL Renderer that this Game is using.
|
||||
*
|
||||
* @property {Phaser.Renderer.CanvasRenderer|Phaser.Renderer.WebGLRenderer} renderer
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.renderer = null;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A reference to the HTML Canvas Element on which the renderer is drawing.
|
||||
*
|
||||
* @property {HTMLCanvasElement} canvas
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.canvas = null;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A reference to the Canvas Rendering Context belonging to the Canvas Element this game is rendering to.
|
||||
*
|
||||
* @property {CanvasRenderingContext2D} context
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.context = null;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A flag indicating when this Game instance has finished its boot process.
|
||||
*
|
||||
* @property {boolean} isBooted
|
||||
* @readOnly
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.isBooted = false;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A flag indicating if this Game is currently running its game step or not.
|
||||
*
|
||||
* @property {boolean} isRunning
|
||||
* @readOnly
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.isRunning = false;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* An Event Emitter which is used to broadcast game-level events from the global systems.
|
||||
*
|
||||
* @property {Phaser.Events.EventDispatcher} events
|
||||
* @property {EventEmitter} events
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.events = new EventEmitter();
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* An instance of the Animation Manager.
|
||||
*
|
||||
* The Animation Manager is a global system responsible for managing all animations used within your game.
|
||||
*
|
||||
* @property {Phaser.Animations.AnimationManager} anims
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.anims = new AnimationManager(this);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* An instance of the Texture Manager.
|
||||
*
|
||||
* The Texture Manager is a global system responsible for managing all textures being used by your game.
|
||||
*
|
||||
* @property {Phaser.Textures.TextureManager} textures
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.textures = new TextureManager(this);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* An instance of the Cache Manager.
|
||||
*
|
||||
* The Cache Manager is a global system responsible for caching, accessing and releasing external game assets.
|
||||
*
|
||||
* @property {Phaser.Cache.CacheManager} cache
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.cache = new CacheManager(this);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {[type]} registry
|
||||
* @property {Phaser.Data} registry
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.registry = new Data(this);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* An instance of the Input Manager.
|
||||
*
|
||||
* The Input Manager is a global system responsible for the capture of browser-level input events.
|
||||
*
|
||||
* @property {Phaser.Input.InputManager} input
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.input = new InputManager(this, this.config);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* An instance of the Scene Manager.
|
||||
*
|
||||
* The Scene Manager is a global system responsible for creating, modifying and updating the Scenes in your game.
|
||||
*
|
||||
* @property {Phaser.Scenes.SceneManager} scene
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.scene = new SceneManager(this, this.config.sceneConfig);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A reference to the Device inspector.
|
||||
*
|
||||
* Contains information about the device running this game, such as OS, browser vendor and feature support.
|
||||
* Used by various systems to determine capabilities and code paths.
|
||||
*
|
||||
* @property {Phaser.Device} device
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.device = Device;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* An instance of the base Sound Manager.
|
||||
*
|
||||
* The Sound Manager is a global system responsible for the playback and updating of all audio in your game.
|
||||
*
|
||||
* @property {Phaser.BaseSoundManager} sound
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.sound = SoundManagerCreator.create(this);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* An instance of the Time Step.
|
||||
*
|
||||
* The Time Step is a global system responsible for setting-up and responding to the browser frame events, processing
|
||||
* them and calculating delta values. It then automatically calls the game step.
|
||||
*
|
||||
* @property {Phaser.Boot.TimeStep} loop
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.loop = new TimeStep(this, this.config.fps);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* An instance of the Plugin Manager.
|
||||
*
|
||||
* The Plugin Manager is a global system that allows plugins to register themselves with it, and can then install
|
||||
* those plugins into Scenes as required.
|
||||
*
|
||||
* @property {Phaser.Plugins.PluginManager} plugins
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.plugins = new PluginManager(this, this.config);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The `onStepCallback` is a callback that is fired each time the Time Step ticks.
|
||||
* It is set automatically when the Game boot process has completed.
|
||||
*
|
||||
* @property {function} onStepCallback
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.onStepCallback = NOOP;
|
||||
|
||||
|
@ -170,9 +218,22 @@ var Game = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Game boot event.
|
||||
*
|
||||
* This is an internal event dispatched when the game has finished booting, but before it is ready to start running.
|
||||
* The global systems use this event to know when to set themselves up, dispatching their own `ready` events as required.
|
||||
*
|
||||
* @event Phaser.Game#boot
|
||||
*/
|
||||
|
||||
/**
|
||||
* This method is called automatically when the DOM is ready. It is responsible for creating the renderer,
|
||||
* displaying the Debug Header, adding the game canvas to the DOM and emitting the 'boot' event.
|
||||
* It listens for a 'ready' event from the base systems and once received it will call `Game.start`.
|
||||
*
|
||||
* @method Phaser.Game#boot
|
||||
* @protected
|
||||
* @fires Phaser.Game#boot
|
||||
* @since 3.0.0
|
||||
*/
|
||||
boot: function ()
|
||||
|
@ -194,9 +255,12 @@ var Game = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Called automatically by Game.boot once all of the global systems have finished setting themselves up.
|
||||
* By this point the Game is now ready to start the main loop running.
|
||||
* It will also enable the Visibility Handler.
|
||||
*
|
||||
* @method Phaser.Game#start
|
||||
* @protected
|
||||
* @since 3.0.0
|
||||
*/
|
||||
start: function ()
|
||||
|
@ -216,9 +280,37 @@ var Game = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Game Pre-Render event.
|
||||
*
|
||||
* This event is dispatched immediately before any of the Scenes have started to render.
|
||||
* The renderer will already have been initialized this frame, clearing itself and preparing to receive
|
||||
* the Scenes for rendering, but it won't have actually drawn anything yet.
|
||||
*
|
||||
* @event Phaser.Game#prerender
|
||||
* @param {Phaser.Renderer.CanvasRenderer|Phaser.Renderer.WebGLRenderer} renderer - A reference to the current renderer.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Game Post-Render event.
|
||||
*
|
||||
* This event is dispatched right at the end of the render process.
|
||||
* Every Scene will have rendered and drawn to the canvas.
|
||||
*
|
||||
* @event Phaser.Game#postrender
|
||||
* @param {Phaser.Renderer.CanvasRenderer|Phaser.Renderer.WebGLRenderer} renderer - A reference to the current renderer.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The main Game Step. Called automatically by the Time Step, once per browser frame (typically as a result of
|
||||
* Request Animation Frame, or Set Timeout on very old browsers.)
|
||||
*
|
||||
* The step will update the global managers first, then proceed to update each Scene in turn, via the Scene Manager.
|
||||
*
|
||||
* It will then render each Scene in turn, via the Renderer. This process emits `prerender` and `postrender` events.
|
||||
*
|
||||
* @method Phaser.Game#step
|
||||
* @fires Phaser.Game#prerender
|
||||
* @fires Phaser.Game#postrender
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout.
|
||||
|
@ -254,10 +346,20 @@ var Game = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Game Pause event.
|
||||
*
|
||||
* This event is dispatched when the game loop enters a paused state, usually as a result of the Visibility Handler.
|
||||
*
|
||||
* @event Phaser.Game#pause
|
||||
*/
|
||||
|
||||
/**
|
||||
* Called automatically by the Visibility Handler.
|
||||
* This will pause the main loop and then emit a pause event.
|
||||
*
|
||||
* @method Phaser.Game#onHidden
|
||||
* @protected
|
||||
* @fires Phaser.Game#pause
|
||||
* @since 3.0.0
|
||||
*/
|
||||
onHidden: function ()
|
||||
|
@ -268,10 +370,20 @@ var Game = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Game Resume event.
|
||||
*
|
||||
* This event is dispatched when the game loop leaves a paused state and resumes running.
|
||||
*
|
||||
* @event Phaser.Game#resume
|
||||
*/
|
||||
|
||||
/**
|
||||
* Called automatically by the Visibility Handler.
|
||||
* This will resume the main loop and then emit a resume event.
|
||||
*
|
||||
* @method Phaser.Game#onVisible
|
||||
* @protected
|
||||
* @fires Phaser.Game#resume
|
||||
* @since 3.0.0
|
||||
*/
|
||||
onVisible: function ()
|
||||
|
@ -282,7 +394,8 @@ var Game = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Called automatically by the Visibility Handler.
|
||||
* This will set the main loop into a 'blurred' state, which pauses it.
|
||||
*
|
||||
* @method Phaser.Game#onBlur
|
||||
* @protected
|
||||
|
@ -294,7 +407,8 @@ var Game = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Called automatically by the Visibility Handler.
|
||||
* This will set the main loop into a 'focused' state, which resumes it.
|
||||
*
|
||||
* @method Phaser.Game#onFocus
|
||||
* @protected
|
||||
|
@ -303,6 +417,17 @@ var Game = new Class({
|
|||
onFocus: function ()
|
||||
{
|
||||
this.loop.focus();
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroys this Phaser.Game instance, all global systems, all sub-systems and all Scenes.
|
||||
*
|
||||
* @method Phaser.Game#destroy
|
||||
* @since 3.0.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -26,8 +26,8 @@ var TimeStep = new Class({
|
|||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Game} game - [description]
|
||||
* @param {FPSConfig]} config - [description]
|
||||
* @param {Phaser.Game} game - A reference to the Phaser.Game instance that owns this Time Step.
|
||||
* @param {FPSConfig} config
|
||||
*/
|
||||
function TimeStep (game, config)
|
||||
{
|
||||
|
@ -36,6 +36,7 @@ var TimeStep = new Class({
|
|||
*
|
||||
* @property {Phaser.Game} game
|
||||
* @readOnly
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
|
@ -44,64 +45,82 @@ var TimeStep = new Class({
|
|||
*
|
||||
* @property {Phaser.DOM.RequestAnimationFrame} raf
|
||||
* @readOnly
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.raf = new RequestAnimationFrame();
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A flag that is set once the TimeStep has started running and toggled when it stops.
|
||||
*
|
||||
* @property {boolean} started
|
||||
* @readOnly
|
||||
* @default false
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.started = false;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A flag that is set once the TimeStep has started running and toggled when it stops.
|
||||
* The difference between this value and `started` is that `running` is toggled when
|
||||
* the TimeStep is sent to sleep, where-as `started` remains `true`, only changing if
|
||||
* the TimeStep is actually stopped, not just paused.
|
||||
*
|
||||
* @property {boolean} running
|
||||
* @readOnly
|
||||
* @default false
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.running = false;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The minimum fps rate you want the Time Step to run at.
|
||||
*
|
||||
* @property {integer} minFps
|
||||
* @default 5
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.minFps = GetValue(config, 'min', 5);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The target fps rate for the Time Step to run at.
|
||||
*
|
||||
* Setting this value will not actually change the speed at which the browser runs, that is beyond
|
||||
* the control of Phaser. Instead, it allows you to determine performance issues and if the Time Step
|
||||
* is spiraling out of control.
|
||||
*
|
||||
* @property {integer} targetFps
|
||||
* @default 60
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.targetFps = GetValue(config, 'target', 60);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The minFps value in ms.
|
||||
* Defaults to 200ms between frames (i.e. super slow!)
|
||||
*
|
||||
* @property {number} _min
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._min = 1000 / this.minFps; // 200ms between frames (i.e. super slow!)
|
||||
this._min = 1000 / this.minFps;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The targetFps value in ms.
|
||||
* Defaults to 16.66ms between frames (i.e. normal)
|
||||
*
|
||||
* @property {number} _target
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._target = 1000 / this.targetFps; // 16.666ms between frames (i.e. normal)
|
||||
|
||||
// 200 / 1000 = 0.2 (5fps)
|
||||
// 8.333 / 1000 = 0.008333 (120fps)
|
||||
// 16.666 / 1000 = 0.01666 (60fps)
|
||||
this._target = 1000 / this.targetFps;
|
||||
|
||||
/**
|
||||
* An exponential moving average of the frames per second.
|
||||
*
|
||||
* @property {integer} actualFps
|
||||
* @readOnly
|
||||
* @default 60
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.actualFps = this.targetFps;
|
||||
|
||||
|
@ -110,29 +129,38 @@ var TimeStep = new Class({
|
|||
*
|
||||
* @property {integer} nextFpsUpdate
|
||||
* @readOnly
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.nextFpsUpdate = 0;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The number of frames processed this second.
|
||||
*
|
||||
* @property {integer} framesThisSecond
|
||||
* @readOnly
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.framesThisSecond = 0;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A callback to be invoked each time the Time Step steps.
|
||||
*
|
||||
* @property {function} callback
|
||||
* @default NOOP
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.callback = NOOP;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* You can force the Time Step to use Set Timeout instead of Request Animation Frame by setting
|
||||
* the `forceSetTimeOut` property to `true` in the Game Configuration object. It cannot be changed at run-time.
|
||||
*
|
||||
* @property {boolean} forceSetTimeOut
|
||||
* @readOnly
|
||||
* @default false
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.forceSetTimeOut = GetValue(config, 'forceSetTimeOut', false);
|
||||
|
||||
|
@ -140,6 +168,8 @@ var TimeStep = new Class({
|
|||
* [description]
|
||||
*
|
||||
* @property {integer} time
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.time = 0;
|
||||
|
||||
|
@ -147,6 +177,8 @@ var TimeStep = new Class({
|
|||
* [description]
|
||||
*
|
||||
* @property {integer} startTime
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.startTime = 0;
|
||||
|
||||
|
@ -154,6 +186,8 @@ var TimeStep = new Class({
|
|||
* [description]
|
||||
*
|
||||
* @property {integer} lastTime
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.lastTime = 0;
|
||||
|
||||
|
@ -162,6 +196,8 @@ var TimeStep = new Class({
|
|||
*
|
||||
* @property {integer} frame
|
||||
* @readOnly
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.frame = 0;
|
||||
|
||||
|
@ -170,6 +206,8 @@ var TimeStep = new Class({
|
|||
*
|
||||
* @property {boolean} inFocus
|
||||
* @readOnly
|
||||
* @default true
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.inFocus = true;
|
||||
|
||||
|
@ -178,6 +216,8 @@ var TimeStep = new Class({
|
|||
*
|
||||
* @property {integer} _pauseTime
|
||||
* @private
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._pauseTime = 0;
|
||||
|
||||
|
@ -186,6 +226,8 @@ var TimeStep = new Class({
|
|||
*
|
||||
* @property {integer} _coolDown
|
||||
* @private
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._coolDown = 0;
|
||||
|
||||
|
@ -193,6 +235,8 @@ var TimeStep = new Class({
|
|||
* [description]
|
||||
*
|
||||
* @property {integer} delta
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.delta = 0;
|
||||
|
||||
|
@ -200,6 +244,8 @@ var TimeStep = new Class({
|
|||
* [description]
|
||||
*
|
||||
* @property {integer} deltaIndex
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.deltaIndex = 0;
|
||||
|
||||
|
@ -207,6 +253,8 @@ var TimeStep = new Class({
|
|||
* [description]
|
||||
*
|
||||
* @property {array} deltaHistory
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.deltaHistory = [];
|
||||
|
||||
|
@ -215,6 +263,7 @@ var TimeStep = new Class({
|
|||
*
|
||||
* @property {integer} deltaSmoothingMax
|
||||
* @default 10
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.deltaSmoothingMax = GetValue(config, 'deltaHistory', 10);
|
||||
|
||||
|
@ -223,6 +272,7 @@ var TimeStep = new Class({
|
|||
*
|
||||
* @property {integer} panicMax
|
||||
* @default 120
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.panicMax = GetValue(config, 'panicMax', 120);
|
||||
|
||||
|
@ -232,6 +282,8 @@ var TimeStep = new Class({
|
|||
* So please be careful when using this value in calculations.
|
||||
*
|
||||
* @property {number} rawDelta
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.rawDelta = 0;
|
||||
},
|
||||
|
@ -261,7 +313,7 @@ var TimeStep = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* Called when the visibility API says the game is 'hidden' (tab switch, etc)
|
||||
* Called when the visibility API says the game is 'hidden' (tab switch out of view, etc)
|
||||
*
|
||||
* @method Phaser.Boot.TimeStep#pause
|
||||
* @since 3.0.0
|
||||
|
@ -272,7 +324,7 @@ var TimeStep = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* Called when the visibility API says the game is 'visible' again (tab switch, etc)
|
||||
* Called when the visibility API says the game is 'visible' again (tab switch back into view, etc)
|
||||
*
|
||||
* @method Phaser.Boot.TimeStep#resume
|
||||
* @since 3.0.0
|
||||
|
@ -314,12 +366,13 @@ var TimeStep = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Starts the Time Step running, if it is not already doing so.
|
||||
* Called automatically by the Game Boot process.
|
||||
*
|
||||
* @method Phaser.Boot.TimeStep#start
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {function} callback - [description]
|
||||
* @param {function} callback - The callback to be invoked each time the Time Step steps.
|
||||
*/
|
||||
start: function (callback)
|
||||
{
|
||||
|
@ -346,7 +399,9 @@ var TimeStep = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The main step method. This is called each time the browser updates, either by Request Animation Frame,
|
||||
* or by Set Timeout. It is responsible for calculating the delta values, frame totals, cool down history and more.
|
||||
* You generally should never call this method directly.
|
||||
*
|
||||
* @method Phaser.Boot.TimeStep#step
|
||||
* @since 3.0.0
|
||||
|
@ -461,7 +516,7 @@ var TimeStep = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Manually calls TimeStep.step, passing in the performance.now value to it.
|
||||
*
|
||||
* @method Phaser.Boot.TimeStep#tick
|
||||
* @since 3.0.0
|
||||
|
@ -472,7 +527,7 @@ var TimeStep = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Sends the TimeStep to sleep, stopping Request Animation Frame (or SetTimeout) and toggling the `running` flag to false.
|
||||
*
|
||||
* @method Phaser.Boot.TimeStep#sleep
|
||||
* @since 3.0.0
|
||||
|
@ -488,12 +543,13 @@ var TimeStep = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Wakes-up the TimeStep, restarting Request Animation Frame (or SetTimeout) and toggling the `running` flag to true.
|
||||
* The `seamless` argument controls if the wake-up should adjust the start time or not.
|
||||
*
|
||||
* @method Phaser.Boot.TimeStep#wake
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {boolean} [seamless=false] - [description]
|
||||
* @param {boolean} [seamless=false] - Adjust the startTime based on the lastTime values.
|
||||
*/
|
||||
wake: function (seamless)
|
||||
{
|
||||
|
@ -514,42 +570,12 @@ var TimeStep = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Boot.TimeStep#setFps
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {integer} value - [description]
|
||||
*/
|
||||
setFps: function (value)
|
||||
{
|
||||
this.sleep();
|
||||
|
||||
this.fps = value;
|
||||
|
||||
this.wake();
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Boot.TimeStep#getFps
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {integer} [description]
|
||||
*/
|
||||
getFps: function ()
|
||||
{
|
||||
return this.fps;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Stops the TimeStep running.
|
||||
*
|
||||
* @method Phaser.Boot.TimeStep#stop
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
* @return {Phaser.Boot.TimeStep} The TimeStep object.
|
||||
*/
|
||||
stop: function ()
|
||||
{
|
||||
|
@ -562,7 +588,8 @@ var TimeStep = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Destroys the TimeStep. This will stop Request Animation Frame, stop the step, clear the callbacks and null
|
||||
* any objects.
|
||||
*
|
||||
* @method Phaser.Boot.TimeStep#destroy
|
||||
* @since 3.0.0
|
||||
|
@ -570,6 +597,10 @@ var TimeStep = new Class({
|
|||
destroy: function ()
|
||||
{
|
||||
this.stop();
|
||||
|
||||
this.callback = null;
|
||||
this.raf = null;
|
||||
this.game = null;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -1,10 +1,48 @@
|
|||
/**
|
||||
* [description]
|
||||
* Visibility Handler hidden event.
|
||||
*
|
||||
* The document in which the Game is embedded has entered a hidden state.
|
||||
*
|
||||
* @event Phaser.Boot.VisibilityHandler#hidden
|
||||
*/
|
||||
|
||||
/**
|
||||
* Visibility Handler visible event.
|
||||
*
|
||||
* The document in which the Game is embedded has entered a visible state.
|
||||
*
|
||||
* @event Phaser.Boot.VisibilityHandler#visible
|
||||
*/
|
||||
|
||||
/**
|
||||
* Visibility Handler blur event.
|
||||
*
|
||||
* The window in which the Game is embedded has entered a blurred state.
|
||||
*
|
||||
* @event Phaser.Boot.VisibilityHandler#blur
|
||||
*/
|
||||
|
||||
/**
|
||||
* Visibility Handler focus event.
|
||||
*
|
||||
* The window in which the Game is embedded has entered a focused state.
|
||||
*
|
||||
* @event Phaser.Boot.VisibilityHandler#focus
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Visibility Handler is responsible for listening out for document level visibility change events.
|
||||
* This includes `visibilitychange` if the browser supports it, and blur and focus events. It then uses
|
||||
* the provided Event Emitter and fires the related events.
|
||||
*
|
||||
* @function Phaser.Boot.VisibilityHandler
|
||||
* @fires Phaser.Boot.VisibilityHandler#hidden
|
||||
* @fires Phaser.Boot.VisibilityHandler#visible
|
||||
* @fires Phaser.Boot.VisibilityHandler#blur
|
||||
* @fires Phaser.Boot.VisibilityHandler#focus
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Events.EventDispatcher} eventEmitter - The EventDispatcher that will dispatch the visibility events.
|
||||
* @param {Phaser.EventEmitter} eventEmitter - The EventEmitter that will emit the visibility events.
|
||||
*/
|
||||
var VisibilityHandler = function (eventEmitter)
|
||||
{
|
||||
|
@ -45,16 +83,10 @@ var VisibilityHandler = function (eventEmitter)
|
|||
}
|
||||
};
|
||||
|
||||
// Does browser support it?
|
||||
// If not (like in IE9 or old Android) we need to fall back to blur / focus
|
||||
if (hiddenVar)
|
||||
{
|
||||
document.addEventListener(hiddenVar, onChange, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log('Fallback TODO');
|
||||
}
|
||||
|
||||
window.onblur = function ()
|
||||
{
|
||||
|
|
83
src/cache/BaseCache.js
vendored
83
src/cache/BaseCache.js
vendored
|
@ -7,7 +7,11 @@ var BaseCache = new Class({
|
|||
initialize:
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The BaseCache is a base Cache class that can be used for storing references to any kind of data.
|
||||
*
|
||||
* Data can be added, retrieved and removed based on the given keys.
|
||||
*
|
||||
* Keys are string-based.
|
||||
*
|
||||
* @class BaseCache
|
||||
* @memberOf Phaser.Cache
|
||||
|
@ -17,46 +21,66 @@ var BaseCache = new Class({
|
|||
function BaseCache ()
|
||||
{
|
||||
/**
|
||||
* [description]
|
||||
* The Map in which the cache objects are stored.
|
||||
*
|
||||
* You can query the Map directly or use the BaseCache methods.
|
||||
*
|
||||
* @property {Phaser.Structs.Map} entries
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.entries = new CustomMap();
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* An instance of EventEmitter used by the cache to emit related events.
|
||||
*
|
||||
* @property {Phaser.Events.EventDispatcher} events
|
||||
* @property {Phaser.EventEmitter} events
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.events = new EventEmitter();
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Cache add event.
|
||||
*
|
||||
* This event is fired by the Cache each time a new object is added to it.
|
||||
*
|
||||
* @event Phaser.Cache.BaseCache#add
|
||||
* @param {Phaser.Cache.BaseCache} The BaseCache to which the object was added.
|
||||
* @param {string} The key of the object added to the cache.
|
||||
* @param {any} A reference to the object added to the cache.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Adds an item to this cache. The item is referenced by a unique string, which you are responsible
|
||||
* for setting and keeping track of. The item can only be retrieved by using this string.
|
||||
*
|
||||
* @method Phaser.Cache.BaseCache#add
|
||||
* @fires CacheAddEvent
|
||||
* @fires Phaser.Cache.BaseCache#add
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key [description]
|
||||
* @param {any} data [description]
|
||||
* @param {string} key - The unique key by which the data added to the cache will be referenced.
|
||||
* @param {any} data - The data to be stored in the cache.
|
||||
*
|
||||
* @return {Phaser.Cache.BaseCache} This BaseCache object.
|
||||
*/
|
||||
add: function (key, data)
|
||||
{
|
||||
this.entries.set(key, data);
|
||||
|
||||
this.events.emit('add', this, key, data);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Checks if this cache contains an item matching the given key.
|
||||
*
|
||||
* @method Phaser.Cache.BaseCache#has
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key [description]
|
||||
* @param {string} key - The unique key of the item to be checked in this cache.
|
||||
*
|
||||
* @return {boolean} [description]
|
||||
* @return {boolean} Returns `true` if the cache contains an item matching the given key, otherwise `false`.
|
||||
*/
|
||||
has: function (key)
|
||||
{
|
||||
|
@ -64,14 +88,14 @@ var BaseCache = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Gets an item from this cache based on the given key.
|
||||
*
|
||||
* @method Phaser.Cache.BaseCache#get
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key [description]
|
||||
* @param {string} key - The unique key of the item to be retrieved from this cache.
|
||||
*
|
||||
* @return {any} [description]
|
||||
* @return {any} The item in the cache, or `null` if no item matching the given key was found.
|
||||
*/
|
||||
get: function (key)
|
||||
{
|
||||
|
@ -79,13 +103,30 @@ var BaseCache = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Cache remove event.
|
||||
*
|
||||
* This event is fired by the Cache each time an object is removed from it.
|
||||
*
|
||||
* @event Phaser.Cache.BaseCache#remove
|
||||
* @param {Phaser.Cache.BaseCache} The BaseCache from which the object was removed.
|
||||
* @param {string} The key of the object removed from the cache.
|
||||
* @param {any} The object that was removed from the cache.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Removes and item from this cache based on the given key.
|
||||
*
|
||||
* If an entry matching the key is found it is removed from the cache and a `remove` event emitted.
|
||||
* No additional checks are done on the item removed. If other systems or parts of your game code
|
||||
* are relying on this item, it is up to you to sever those relationships prior to removing the item.
|
||||
*
|
||||
* @method Phaser.Cache.BaseCache#remove
|
||||
* @fires CacheRemoveEvent
|
||||
* @fires Phaser.Cache.BaseCache#remove
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key [description]
|
||||
* @param {string} key - The unique key of the item to remove from the cache.
|
||||
*
|
||||
* @return {Phaser.Cache.BaseCache} This BaseCache object.
|
||||
*/
|
||||
remove: function (key)
|
||||
{
|
||||
|
@ -97,10 +138,12 @@ var BaseCache = new Class({
|
|||
|
||||
this.events.emit('remove', this, key, entry.data);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Destroys this cache and all items within it.
|
||||
*
|
||||
* @method Phaser.Cache.BaseCache#destroy
|
||||
* @since 3.0.0
|
||||
|
@ -108,6 +151,10 @@ var BaseCache = new Class({
|
|||
destroy: function ()
|
||||
{
|
||||
this.entries.clear();
|
||||
this.events.removeAllListeners();
|
||||
|
||||
this.entries = null;
|
||||
this.events = null;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
102
src/cache/CacheManager.js
vendored
102
src/cache/CacheManager.js
vendored
|
@ -6,142 +6,190 @@ var CacheManager = new Class({
|
|||
initialize:
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The Cache Manager is the global cache owned and maintained by the Game instance.
|
||||
*
|
||||
* Various systems, such as the file Loader, rely on this cache in order to store the files
|
||||
* it has loaded. The manager itself doesn't store any files, but instead owns multiple BaseCache
|
||||
* instances, one per type of file. You can also add your own custom caches.
|
||||
*
|
||||
* @class CacheManager
|
||||
* @memberOf Phaser.Cache
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Game} game - [description]
|
||||
* @param {Phaser.Game} game - A reference to the Phaser.Game instance that owns this CacheManager.
|
||||
*/
|
||||
function CacheManager (game)
|
||||
{
|
||||
/**
|
||||
* [description]
|
||||
* A reference to the Phaser.Game instance that owns this CacheManager.
|
||||
*
|
||||
* @property {Phaser.Game} game
|
||||
* @protected
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A Cache storing all binary files, typically added via the Loader.
|
||||
*
|
||||
* @property {Phaser.Cache.BaseCache} binary
|
||||
* @protected
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.binary = new BaseCache();
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A Cache storing all bitmap font data files, typically added via the Loader.
|
||||
* Only the font data is stored in this cache, the textures are part of the Texture Manager.
|
||||
*
|
||||
* @property {Phaser.Cache.BaseCache} bitmapFont
|
||||
* @protected
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.bitmapFont = new BaseCache();
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A Cache storing all JSON data files, typically added via the Loader.
|
||||
*
|
||||
* @property {Phaser.Cache.BaseCache} json
|
||||
* @protected
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.json = new BaseCache();
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A Cache storing all physics data files, typically added via the Loader.
|
||||
*
|
||||
* @property {Phaser.Cache.BaseCache} physics
|
||||
* @protected
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.physics = new BaseCache();
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A Cache storing all shader source files, typically added via the Loader.
|
||||
*
|
||||
* @property {Phaser.Cache.BaseCache} shader
|
||||
* @protected
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.shader = new BaseCache();
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A Cache storing all non-streaming audio files, typically added via the Loader.
|
||||
*
|
||||
* @property {Phaser.Cache.BaseCache} audio
|
||||
* @protected
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.audio = new BaseCache();
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A Cache storing all text files, typically added via the Loader.
|
||||
*
|
||||
* @property {Phaser.Cache.BaseCache} text
|
||||
* @protected
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.text = new BaseCache();
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A Cache storing all WaveFront OBJ files, typically added via the Loader.
|
||||
*
|
||||
* @property {Phaser.Cache.BaseCache} obj
|
||||
* @protected
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.obj = new BaseCache();
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A Cache storing all tilemap data files, typically added via the Loader.
|
||||
* Only the data is stored in this cache, the textures are part of the Texture Manager.
|
||||
*
|
||||
* @property {Phaser.Cache.BaseCache} tilemap
|
||||
* @protected
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.tilemap = new BaseCache();
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {Phaser.Cache.BaseCache} video
|
||||
* @protected
|
||||
*/
|
||||
this.video = new BaseCache();
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A Cache storing all xml data files, typically added via the Loader.
|
||||
*
|
||||
* @property {Phaser.Cache.BaseCache} xml
|
||||
* @protected
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.xml = new BaseCache();
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* An object that contains your own custom BaseCache entries.
|
||||
* Add to this via the `addCustom` method.
|
||||
*
|
||||
* @property {object.<Phaser.Cache.BaseCache>} custom
|
||||
* @protected
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.custom = {};
|
||||
},
|
||||
|
||||
// Add your own custom Cache entry, available under Cache.custom.key
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Add your own custom Cache for storing your own files.
|
||||
* The cache will be available under `Cache.custom.key`.
|
||||
* The cache will only be created if the key is not already in use.
|
||||
*
|
||||
* @method Phaser.Cache.CacheManager#addCustom
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} key - [description]
|
||||
* @param {string} key - The unique key of your custom cache.
|
||||
*
|
||||
* @return {Phaser.Cache.BaseCache} [description]
|
||||
* @return {Phaser.Cache.BaseCache} A reference to the BaseCache that was created. If the key was already in use, a reference to the existing cache is returned instead.
|
||||
*/
|
||||
addCustom: function (key)
|
||||
{
|
||||
if (!this.custom.hasOwnProperty(key))
|
||||
{
|
||||
this.custom[key] = new BaseCache();
|
||||
}
|
||||
|
||||
return this.custom[key];
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes all entries from all BaseCaches and destroys all custom caches.
|
||||
*
|
||||
* @method Phaser.Cache.CacheManager#destroy
|
||||
* @since 3.0.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
var keys = [
|
||||
'binary',
|
||||
'bitmapFont',
|
||||
'json',
|
||||
'physics',
|
||||
'shader',
|
||||
'audio',
|
||||
'text',
|
||||
'obj',
|
||||
'tilemap',
|
||||
'xml'
|
||||
];
|
||||
|
||||
for (var i = 0; i < keys.length; i++)
|
||||
{
|
||||
this[keys[i]].destroy();
|
||||
this[keys[i]] = null;
|
||||
}
|
||||
|
||||
for (var key in this.custom)
|
||||
{
|
||||
this.custom[key].destroy();
|
||||
}
|
||||
|
||||
this.custom = null;
|
||||
|
||||
this.game = null;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -5,70 +5,372 @@ var TransformMatrix = require('../../gameobjects/components/TransformMatrix');
|
|||
var ValueToColor = require('../../display/color/ValueToColor');
|
||||
var Vector2 = require('../../math/Vector2');
|
||||
|
||||
// Phaser.Cameras.Scene2D.Camera
|
||||
|
||||
var Camera = new Class({
|
||||
|
||||
initialize:
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @class Camera
|
||||
* @memberOf Phaser.Cameras.Scene2D
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} x - The x position of the Camera, relative to the top-left of the game canvas.
|
||||
* @param {number} y - The y position of the Camera, relative to the top-left of the game canvas.
|
||||
* @param {number} width - The width of the Camera, in pixels.
|
||||
* @param {number} height - The height of the Camera, in pixels.
|
||||
*/
|
||||
function Camera (x, y, width, height)
|
||||
{
|
||||
/**
|
||||
* A reference to the Scene this camera belongs to.
|
||||
*
|
||||
* @property {Phaser.Scene} scene
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.scene;
|
||||
|
||||
/**
|
||||
* The name of the Camera. This is left empty for your own use.
|
||||
*
|
||||
* @property {string} name
|
||||
* @since 3.0.0
|
||||
* @default ''
|
||||
*/
|
||||
this.name = '';
|
||||
|
||||
/**
|
||||
* The x position of the Camera, relative to the top-left of the game canvas.
|
||||
*
|
||||
* @property {number} x
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.x = x;
|
||||
|
||||
/**
|
||||
* The y position of the Camera, relative to the top-left of the game canvas.
|
||||
*
|
||||
* @property {number} y
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.y = y;
|
||||
|
||||
/**
|
||||
* The width of the Camera, in pixels.
|
||||
*
|
||||
* @property {number} width
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.width = width;
|
||||
|
||||
/**
|
||||
* The height of the Camera, in pixels.
|
||||
*
|
||||
* @property {number} height
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.height = height;
|
||||
|
||||
/**
|
||||
* Should this camera round its pixel values to integers?
|
||||
*
|
||||
* @property {boolean} roundPixels
|
||||
* @since 3.0.0
|
||||
* @default false
|
||||
*/
|
||||
this.roundPixels = false;
|
||||
|
||||
// Bounds
|
||||
/**
|
||||
* Is this Camera using a bounds to restrict scrolling movement?
|
||||
* Set this property along with the bounds via `Camera.setBounds`.
|
||||
*
|
||||
* @property {boolean} useBounds
|
||||
* @since 3.0.0
|
||||
* @default false
|
||||
*/
|
||||
this.useBounds = false;
|
||||
|
||||
/**
|
||||
* The bounds the camera is restrained to during scrolling.
|
||||
*
|
||||
* @property {Phaser.Geom.Rectangle} _bounds
|
||||
* @since 3.0.0
|
||||
* @private
|
||||
*/
|
||||
this._bounds = new Rectangle();
|
||||
|
||||
/**
|
||||
* Does this Camera allow the Game Objects it renders to receive input events?
|
||||
*
|
||||
* @property {boolean} inputEnabled
|
||||
* @default true
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.inputEnabled = true;
|
||||
|
||||
this.scrollX = 0.0;
|
||||
this.scrollY = 0.0;
|
||||
this.zoom = 1.0;
|
||||
this.rotation = 0.0;
|
||||
/**
|
||||
* The horizontal scroll position of this camera.
|
||||
* Optionally restricted via the Camera bounds.
|
||||
*
|
||||
* @property {number} scrollX
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.scrollX = 0;
|
||||
|
||||
/**
|
||||
* The vertical scroll position of this camera.
|
||||
* Optionally restricted via the Camera bounds.
|
||||
*
|
||||
* @property {number} scrollY
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.scrollY = 0;
|
||||
|
||||
/**
|
||||
* The Camera zoom value. Change this value to zoom in, or out of, a Scene.
|
||||
* Set to 1 to return to the default zoom level.
|
||||
*
|
||||
* @property {float} zoom
|
||||
* @default 1
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.zoom = 1;
|
||||
|
||||
/**
|
||||
* The rotation of the Camera. This influences the rendering of all Game Objects visible by this camera.
|
||||
*
|
||||
* @property {number} rotation
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.rotation = 0;
|
||||
|
||||
/**
|
||||
* A local transform matrix used for internal calculations.
|
||||
*
|
||||
* @property {TransformMatrix} matrix
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.matrix = new TransformMatrix(1, 0, 0, 1, 0, 0);
|
||||
|
||||
/**
|
||||
* Does this Camera have a transparent background?
|
||||
*
|
||||
* @property {boolean} transparent
|
||||
* @default true
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.transparent = true;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* @property {boolean} clearBeforeRender
|
||||
* @default true
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.clearBeforeRender = true;
|
||||
|
||||
/**
|
||||
* The background color of this Camera. Only used if `transparent` is `false`.
|
||||
*
|
||||
* @property {Phaser.Display.Color} backgroundColor
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.backgroundColor = ValueToColor('rgba(0,0,0,0)');
|
||||
|
||||
/**
|
||||
* Should the camera cull Game Objects before rendering?
|
||||
* In some special cases it may be beneficial to disable this.
|
||||
*
|
||||
* @property {boolean} disableCull
|
||||
* @default false
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.disableCull = false;
|
||||
|
||||
/**
|
||||
* A temporary array of culled objects.
|
||||
*
|
||||
* @property {array} culledObjects
|
||||
* @default []
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.culledObjects = [];
|
||||
|
||||
// Shake
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {number} _shakeDuration
|
||||
* @private
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._shakeDuration = 0;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {number} _shakeIntensity
|
||||
* @private
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._shakeIntensity = 0;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {number} _shakeOffsetX
|
||||
* @private
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._shakeOffsetX = 0;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {number} _shakeOffsetY
|
||||
* @private
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._shakeOffsetY = 0;
|
||||
|
||||
// Fade
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {number} _fadeDuration
|
||||
* @private
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._fadeDuration = 0;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {number} _fadeRed
|
||||
* @private
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._fadeRed = 0;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {number} _fadeGreen
|
||||
* @private
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._fadeGreen = 0;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {number} _fadeBlue
|
||||
* @private
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._fadeBlue = 0;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {number} _fadeAlpha
|
||||
* @private
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._fadeAlpha = 0;
|
||||
|
||||
// Flash
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {number} _flashDuration
|
||||
* @private
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._flashDuration = 0;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {number} _flashRed
|
||||
* @private
|
||||
* @default 1
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._flashRed = 1;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {number} _flashGreen
|
||||
* @private
|
||||
* @default 1
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._flashGreen = 1;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {number} _flashBlue
|
||||
* @private
|
||||
* @default 1
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._flashBlue = 1;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {number} _flashAlpha
|
||||
* @private
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._flashAlpha = 0;
|
||||
|
||||
// Follow
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {?any} _follow
|
||||
* @private
|
||||
* @default null
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._follow = null;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {integer} _id
|
||||
* @private
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._id = 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Camera#centerToBounds
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
|
||||
*/
|
||||
centerToBounds: function ()
|
||||
{
|
||||
this.scrollX = (this._bounds.width * 0.5) - (this.width * 0.5);
|
||||
|
@ -77,6 +379,14 @@ var Camera = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Camera#centerToSize
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
|
||||
*/
|
||||
centerToSize: function ()
|
||||
{
|
||||
this.scrollX = this.width * 0.5;
|
||||
|
@ -85,6 +395,16 @@ var Camera = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Camera#cull
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} renderableObjects - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
cull: function (renderableObjects)
|
||||
{
|
||||
if (this.disableCull)
|
||||
|
@ -152,6 +472,16 @@ var Camera = new Class({
|
|||
return culledObjects;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Camera#cullHitTest
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} interactiveObjects - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
cullHitTest: function (interactiveObjects)
|
||||
{
|
||||
if (this.disableCull)
|
||||
|
@ -218,6 +548,16 @@ var Camera = new Class({
|
|||
return culledObjects;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Camera#cullTilemap
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} tilemap - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
cullTilemap: function (tilemap)
|
||||
{
|
||||
var cameraMatrix = this.matrix.matrix;
|
||||
|
@ -274,23 +614,29 @@ var Camera = new Class({
|
|||
return culledObjects;
|
||||
},
|
||||
|
||||
destroy: function ()
|
||||
{
|
||||
this._bounds = undefined;
|
||||
this.matrix = undefined;
|
||||
this.culledObjects = [];
|
||||
this.scene = undefined;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Camera#fade
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} duration - [description]
|
||||
* @param {number} red - [description]
|
||||
* @param {number} green - [description]
|
||||
* @param {number} blue - [description]
|
||||
* @param {number} force - [description]
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
|
||||
*/
|
||||
fade: function (duration, red, green, blue, force)
|
||||
{
|
||||
if (red === undefined) { red = 0.0; }
|
||||
if (green === undefined) { green = 0.0; }
|
||||
if (blue === undefined) { blue = 0.0; }
|
||||
if (red === undefined) { red = 0; }
|
||||
if (green === undefined) { green = 0; }
|
||||
if (blue === undefined) { blue = 0; }
|
||||
|
||||
if (!force && this._fadeAlpha > 0.0)
|
||||
if (!force && this._fadeAlpha > 0)
|
||||
{
|
||||
return;
|
||||
return this;
|
||||
}
|
||||
|
||||
this._fadeRed = red;
|
||||
|
@ -304,13 +650,29 @@ var Camera = new Class({
|
|||
|
||||
this._fadeDuration = duration;
|
||||
this._fadeAlpha = Number.MIN_VALUE;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Camera#flash
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} duration - [description]
|
||||
* @param {number} red - [description]
|
||||
* @param {number} green - [description]
|
||||
* @param {number} blue - [description]
|
||||
* @param {number} force - [description]
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
|
||||
*/
|
||||
flash: function (duration, red, green, blue, force)
|
||||
{
|
||||
if (!force && this._flashAlpha > 0.0)
|
||||
{
|
||||
return;
|
||||
return this;
|
||||
}
|
||||
|
||||
if (red === undefined) { red = 1.0; }
|
||||
|
@ -328,8 +690,22 @@ var Camera = new Class({
|
|||
|
||||
this._flashDuration = duration;
|
||||
this._flashAlpha = 1.0;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Camera#getWorldPoint
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} x - [description]
|
||||
* @param {[type]} y - [description]
|
||||
* @param {[type]} output - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
getWorldPoint: function (x, y, output)
|
||||
{
|
||||
if (output === undefined) { output = new Vector2(); }
|
||||
|
@ -381,8 +757,20 @@ var Camera = new Class({
|
|||
return output;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Camera#ignore
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} gameObjectOrArray - [description]
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
|
||||
*/
|
||||
ignore: function (gameObjectOrArray)
|
||||
{
|
||||
|
||||
|
||||
if (gameObjectOrArray instanceof Array)
|
||||
{
|
||||
for (var index = 0; index < gameObjectOrArray.length; ++index)
|
||||
|
@ -394,8 +782,16 @@ var Camera = new Class({
|
|||
{
|
||||
gameObjectOrArray.cameraFilter |= this._id;
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Camera#preRender
|
||||
* @since 3.0.0
|
||||
*/
|
||||
preRender: function ()
|
||||
{
|
||||
var width = this.width;
|
||||
|
@ -455,6 +851,14 @@ var Camera = new Class({
|
|||
matrix.translate(this._shakeOffsetX, this._shakeOffsetY);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Camera#removeBounds
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
|
||||
*/
|
||||
removeBounds: function ()
|
||||
{
|
||||
this.useBounds = false;
|
||||
|
@ -464,6 +868,16 @@ var Camera = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Camera#setAngle
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} value - [description]
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
|
||||
*/
|
||||
setAngle: function (value)
|
||||
{
|
||||
if (value === undefined) { value = 0; }
|
||||
|
@ -473,6 +887,16 @@ var Camera = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Camera#setBackgroundColor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} color - [description]
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
|
||||
*/
|
||||
setBackgroundColor: function (color)
|
||||
{
|
||||
if (color === undefined) { color = 'rgba(0,0,0,0)'; }
|
||||
|
@ -484,6 +908,19 @@ var Camera = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Camera#setBounds
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} x - [description]
|
||||
* @param {[type]} y - [description]
|
||||
* @param {[type]} width - [description]
|
||||
* @param {[type]} height - [description]
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
|
||||
*/
|
||||
setBounds: function (x, y, width, height)
|
||||
{
|
||||
this._bounds.setTo(x, y, width, height);
|
||||
|
@ -493,6 +930,16 @@ var Camera = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Camera#setName
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} value - [description]
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
|
||||
*/
|
||||
setName: function (value)
|
||||
{
|
||||
if (value === undefined) { value = ''; }
|
||||
|
@ -502,6 +949,17 @@ var Camera = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Camera#setPosition
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} x - [description]
|
||||
* @param {[type]} y - [description]
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
|
||||
*/
|
||||
setPosition: function (x, y)
|
||||
{
|
||||
if (y === undefined) { y = x; }
|
||||
|
@ -512,6 +970,16 @@ var Camera = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Camera#setRotation
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} value - [description]
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
|
||||
*/
|
||||
setRotation: function (value)
|
||||
{
|
||||
if (value === undefined) { value = 0; }
|
||||
|
@ -521,6 +989,16 @@ var Camera = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Camera#setRoundPixels
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} value - [description]
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
|
||||
*/
|
||||
setRoundPixels: function (value)
|
||||
{
|
||||
this.roundPixels = value;
|
||||
|
@ -528,6 +1006,16 @@ var Camera = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Camera#setScene
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} scene - [description]
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
|
||||
*/
|
||||
setScene: function (scene)
|
||||
{
|
||||
this.scene = scene;
|
||||
|
@ -535,6 +1023,17 @@ var Camera = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Camera#setScroll
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} x - [description]
|
||||
* @param {[type]} y - [description]
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
|
||||
*/
|
||||
setScroll: function (x, y)
|
||||
{
|
||||
if (y === undefined) { y = x; }
|
||||
|
@ -545,6 +1044,17 @@ var Camera = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Camera#setSize
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} width - [description]
|
||||
* @param {[type]} height - [description]
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
|
||||
*/
|
||||
setSize: function (width, height)
|
||||
{
|
||||
if (height === undefined) { height = width; }
|
||||
|
@ -555,6 +1065,19 @@ var Camera = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Camera#setViewport
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} x - [description]
|
||||
* @param {[type]} y - [description]
|
||||
* @param {[type]} width - [description]
|
||||
* @param {[type]} height - [description]
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
|
||||
*/
|
||||
setViewport: function (x, y, width, height)
|
||||
{
|
||||
this.x = x;
|
||||
|
@ -565,6 +1088,16 @@ var Camera = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Camera#setZoom
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} value - [description]
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
|
||||
*/
|
||||
setZoom: function (value)
|
||||
{
|
||||
if (value === undefined) { value = 1; }
|
||||
|
@ -574,28 +1107,48 @@ var Camera = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Camera#shake
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} duration - [description]
|
||||
* @param {[type]} intensity - [description]
|
||||
* @param {[type]} force - [description]
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
|
||||
*/
|
||||
shake: function (duration, intensity, force)
|
||||
{
|
||||
if (intensity === undefined) { intensity = 0.05; }
|
||||
|
||||
if (!force && (this._shakeOffsetX !== 0.0 || this._shakeOffsetY !== 0.0))
|
||||
if (!force && (this._shakeOffsetX !== 0 || this._shakeOffsetY !== 0))
|
||||
{
|
||||
return;
|
||||
return this;
|
||||
}
|
||||
|
||||
this._shakeDuration = duration;
|
||||
this._shakeIntensity = intensity;
|
||||
this._shakeOffsetX = 0;
|
||||
this._shakeOffsetY = 0;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Camera#startFollow
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} gameObjectOrPoint - [description]
|
||||
* @param {[type]} roundPx - [description]
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
|
||||
*/
|
||||
startFollow: function (gameObjectOrPoint, roundPx)
|
||||
{
|
||||
if (this._follow !== null)
|
||||
{
|
||||
this.stopFollow();
|
||||
}
|
||||
|
||||
this._follow = gameObjectOrPoint;
|
||||
|
||||
if (roundPx !== undefined)
|
||||
|
@ -606,31 +1159,28 @@ var Camera = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Camera#stopFollow
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} This Camera instance.
|
||||
*/
|
||||
stopFollow: function ()
|
||||
{
|
||||
/* do unfollow work here */
|
||||
this._follow = null;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/*
|
||||
camera: {
|
||||
x: int
|
||||
y: int
|
||||
width: int
|
||||
height: int
|
||||
zoom: float
|
||||
rotation: float
|
||||
roundPixels: bool
|
||||
scrollX: float
|
||||
scrollY: float
|
||||
backgroundColor: string
|
||||
bounds: {
|
||||
x: int
|
||||
y: int
|
||||
width: int
|
||||
height: int
|
||||
}
|
||||
}
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Camera#toJSON
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
toJSON: function ()
|
||||
{
|
||||
|
@ -661,6 +1211,15 @@ var Camera = new Class({
|
|||
return output;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Camera#update
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} timestep - [description]
|
||||
* @param {[type]} delta - [description]
|
||||
*/
|
||||
update: function (timestep, delta)
|
||||
{
|
||||
if (this._flashAlpha > 0.0)
|
||||
|
@ -700,7 +1259,21 @@ var Camera = new Class({
|
|||
this._shakeOffsetY = (Math.random() * intensity * this.height * 2 - intensity * this.height) * this.zoom;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Camera#destroy
|
||||
* @since 3.0.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
this._bounds = undefined;
|
||||
this.matrix = undefined;
|
||||
this.culledObjects = [];
|
||||
this.scene = undefined;
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
|
|
|
@ -4,17 +4,36 @@ var GetFastValue = require('../../utils/object/GetFastValue');
|
|||
var PluginManager = require('../../plugins/PluginManager');
|
||||
var RectangleContains = require('../../geom/rectangle/Contains');
|
||||
|
||||
// Phaser.Cameras.Scene2D.CameraManager
|
||||
|
||||
var CameraManager = new Class({
|
||||
|
||||
initialize:
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @class CameraManager
|
||||
* @memberOf Phaser.Cameras.Scene2D
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Scene} scene - The Scene that owns the Camera Manager plugin.
|
||||
*/
|
||||
function CameraManager (scene)
|
||||
{
|
||||
// The Scene that owns this plugin
|
||||
/**
|
||||
* The Scene that owns the Camera Manager plugin.
|
||||
*
|
||||
* @property {Phaser.Scene} scene
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.scene = scene;
|
||||
|
||||
/**
|
||||
* A reference to the Scene.Systems handler for the Scene that owns the Camera Manager.
|
||||
*
|
||||
* @property {Phaser.Scenes.Systems} systems
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.systems = scene.sys;
|
||||
|
||||
if (!scene.sys.settings.isBooted)
|
||||
|
@ -22,9 +41,30 @@ var CameraManager = new Class({
|
|||
scene.sys.events.once('boot', this.boot, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* The current Camera ID.
|
||||
*
|
||||
* @property {number} currentCameraId
|
||||
* @default 1
|
||||
* @readOnly
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.currentCameraId = 1;
|
||||
|
||||
/**
|
||||
* An Array of the Camera objects being managed by this Camera Manager.
|
||||
*
|
||||
* @property {Phaser.Cameras.Scene2D.Camera[]} cameras
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.cameras = [];
|
||||
|
||||
/**
|
||||
* A pool of Camera objects available to be used by the Camera Manager.
|
||||
*
|
||||
* @property {Phaser.Cameras.Scene2D.Camera[]} cameraPool
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.cameraPool = [];
|
||||
|
||||
if (scene.sys.settings.cameras)
|
||||
|
@ -38,10 +78,22 @@ var CameraManager = new Class({
|
|||
this.add();
|
||||
}
|
||||
|
||||
// Set the default camera
|
||||
/**
|
||||
* The default Camera in the Camera Manager.
|
||||
*
|
||||
* @property {Phaser.Cameras.Scene2D.Camera} main
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.main = this.cameras[0];
|
||||
},
|
||||
|
||||
/**
|
||||
* Called when the Camera Manager boots.
|
||||
* Starts the event listeners running.
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.CameraManager#boot
|
||||
* @since 3.0.0
|
||||
*/
|
||||
boot: function ()
|
||||
{
|
||||
var eventEmitter = this.systems.events;
|
||||
|
@ -51,6 +103,21 @@ var CameraManager = new Class({
|
|||
eventEmitter.on('destroy', this.destroy, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.CameraManager#add
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} [x=0] - [description]
|
||||
* @param {number} [y=0] - [description]
|
||||
* @param {number} [width] - [description]
|
||||
* @param {number} [height] - [description]
|
||||
* @param {boolean} [makeMain=false] - [description]
|
||||
* @param {string} [name=''] - [description]
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} [description]
|
||||
*/
|
||||
add: function (x, y, width, height, makeMain, name)
|
||||
{
|
||||
if (x === undefined) { x = 0; }
|
||||
|
@ -90,6 +157,16 @@ var CameraManager = new Class({
|
|||
return camera;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.CameraManager#addExisting
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} [description]
|
||||
*/
|
||||
addExisting: function (camera)
|
||||
{
|
||||
var index = this.cameras.indexOf(camera);
|
||||
|
@ -105,17 +182,35 @@ var CameraManager = new Class({
|
|||
return null;
|
||||
},
|
||||
|
||||
/*
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.CameraManager#addKeyControl
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} config - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
addKeyControl: function (config)
|
||||
{
|
||||
return new KeyControl(config);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.CameraManager#addSmoothedKeyControl
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} config - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
addSmoothedKeyControl: function (config)
|
||||
{
|
||||
return new SmoothedKeyControl(config);
|
||||
},
|
||||
*/
|
||||
|
||||
/*
|
||||
{
|
||||
|
@ -143,6 +238,16 @@ var CameraManager = new Class({
|
|||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.CameraManager#fromJSON
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} config - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
fromJSON: function (config)
|
||||
{
|
||||
if (!Array.isArray(config))
|
||||
|
@ -199,6 +304,16 @@ var CameraManager = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.CameraManager#getCamera
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} name - [description]
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} [description]
|
||||
*/
|
||||
getCamera: function (name)
|
||||
{
|
||||
this.cameras.forEach(function (camera)
|
||||
|
@ -212,6 +327,16 @@ var CameraManager = new Class({
|
|||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.CameraManager#getCameraBelowPointer
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} pointer - [description]
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} [description]
|
||||
*/
|
||||
getCameraBelowPointer: function (pointer)
|
||||
{
|
||||
var cameras = this.cameras;
|
||||
|
@ -228,6 +353,14 @@ var CameraManager = new Class({
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.CameraManager#remove
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
|
||||
*/
|
||||
remove: function (camera)
|
||||
{
|
||||
var cameraIndex = this.cameras.indexOf(camera);
|
||||
|
@ -244,6 +377,16 @@ var CameraManager = new Class({
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.CameraManager#render
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} renderer - [description]
|
||||
* @param {[type]} children - [description]
|
||||
* @param {[type]} interpolation - [description]
|
||||
*/
|
||||
render: function (renderer, children, interpolation)
|
||||
{
|
||||
var cameras = this.cameras;
|
||||
|
@ -258,6 +401,14 @@ var CameraManager = new Class({
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.CameraManager#resetAll
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {Phaser.Cameras.Scene2D.Camera} [description]
|
||||
*/
|
||||
resetAll: function ()
|
||||
{
|
||||
while (this.cameras.length > 0)
|
||||
|
@ -270,6 +421,15 @@ var CameraManager = new Class({
|
|||
return this.main;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.CameraManager#update
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} timestep - [description]
|
||||
* @param {[type]} delta - [description]
|
||||
*/
|
||||
update: function (timestep, delta)
|
||||
{
|
||||
for (var i = 0, l = this.cameras.length; i < l; ++i)
|
||||
|
@ -278,10 +438,23 @@ var CameraManager = new Class({
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.CameraManager#shutdown
|
||||
* @since 3.0.0
|
||||
*/
|
||||
shutdown: function ()
|
||||
{
|
||||
// TODO
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.CameraManager#destroy
|
||||
* @since 3.0.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
this.main = undefined;
|
||||
|
|
|
@ -8,25 +8,109 @@ var GetValue = require('../../utils/object/GetValue');
|
|||
// speed: float OR { x: 0, y: 0 }
|
||||
// })
|
||||
|
||||
// Phaser.Cameras.Controls.Fixed
|
||||
|
||||
var FixedKeyControl = new Class({
|
||||
|
||||
initialize:
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @class FixedKeyControl
|
||||
* @memberOf Phaser.Cameras.Controls
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {object} config - [description]
|
||||
*/
|
||||
function FixedKeyControl (config)
|
||||
{
|
||||
/**
|
||||
* The Camera that this Control will update.
|
||||
*
|
||||
* @property {Phaser.Cameras.Scene2D.Camera} camera
|
||||
* @default null
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.camera = GetValue(config, 'camera', null);
|
||||
|
||||
/**
|
||||
* The Key to be pressed that will move the Camera left.
|
||||
*
|
||||
* @property {Phaser.Input.Keyboard} left
|
||||
* @default null
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.left = GetValue(config, 'left', null);
|
||||
|
||||
/**
|
||||
* The Key to be pressed that will move the Camera right.
|
||||
*
|
||||
* @property {Phaser.Input.Keyboard} right
|
||||
* @default null
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.right = GetValue(config, 'right', null);
|
||||
|
||||
/**
|
||||
* The Key to be pressed that will move the Camera up.
|
||||
*
|
||||
* @property {Phaser.Input.Keyboard} up
|
||||
* @default null
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.up = GetValue(config, 'up', null);
|
||||
|
||||
/**
|
||||
* The Key to be pressed that will move the Camera down.
|
||||
*
|
||||
* @property {Phaser.Input.Keyboard} down
|
||||
* @default null
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.down = GetValue(config, 'down', null);
|
||||
|
||||
/**
|
||||
* The Key to be pressed that will zoom the Camera in.
|
||||
*
|
||||
* @property {Phaser.Input.Keyboard} zoomIn
|
||||
* @default null
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.zoomIn = GetValue(config, 'zoomIn', null);
|
||||
|
||||
/**
|
||||
* The Key to be pressed that will zoom the Camera out.
|
||||
*
|
||||
* @property {Phaser.Input.Keyboard} zoomOut
|
||||
* @default null
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.zoomOut = GetValue(config, 'zoomOut', null);
|
||||
|
||||
/**
|
||||
* The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed.
|
||||
*
|
||||
* @property {float} zoomSpeed
|
||||
* @default 0.01
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.zoomSpeed = GetValue(config, 'zoomSpeed', 0.01);
|
||||
|
||||
/**
|
||||
* The horizontal speed the camera will move.
|
||||
*
|
||||
* @property {float} speedX
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* The vertical speed the camera will move.
|
||||
*
|
||||
* @property {float} speedY
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
var speed = GetValue(config, 'speed', null);
|
||||
|
||||
if (typeof speed === 'number')
|
||||
|
@ -40,11 +124,33 @@ var FixedKeyControl = new Class({
|
|||
this.speedY = GetValue(config, 'speed.y', 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {number} _zoom
|
||||
* @private
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._zoom = 0;
|
||||
|
||||
/**
|
||||
* A flag controlling if the Controls will update the Camera or not.
|
||||
*
|
||||
* @property {boolean} active
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.active = (this.camera !== null);
|
||||
},
|
||||
|
||||
/**
|
||||
* Starts the Key Control running, providing it has been linked to a camera.
|
||||
*
|
||||
* @method Phaser.Cameras.Controls.FixedKeyControl#start
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {Phaser.Cameras.Controls.FixedKeyControl} This Key Control instance.
|
||||
*/
|
||||
start: function ()
|
||||
{
|
||||
this.active = (this.camera !== null);
|
||||
|
@ -52,6 +158,14 @@ var FixedKeyControl = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Stops this Key Control from running. Call `start` to start it again.
|
||||
*
|
||||
* @method Phaser.Cameras.Controls.FixedKeyControl#stop
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {Phaser.Cameras.Controls.FixedKeyControl} This Key Control instance.
|
||||
*/
|
||||
stop: function ()
|
||||
{
|
||||
this.active = false;
|
||||
|
@ -59,6 +173,16 @@ var FixedKeyControl = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Binds this Key Control to a camera.
|
||||
*
|
||||
* @method Phaser.Cameras.Controls.FixedKeyControl#setCamera
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The camera to bind this Key Control to.
|
||||
*
|
||||
* @return {Phaser.Cameras.Controls.FixedKeyControl} This Key Control instance.
|
||||
*/
|
||||
setCamera: function (camera)
|
||||
{
|
||||
this.camera = camera;
|
||||
|
@ -66,6 +190,14 @@ var FixedKeyControl = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Controls.FixedKeyControl#update
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} delta - [description]
|
||||
*/
|
||||
update: function (delta)
|
||||
{
|
||||
if (!this.active)
|
||||
|
@ -112,6 +244,12 @@ var FixedKeyControl = new Class({
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroys this Key Control.
|
||||
*
|
||||
* @method Phaser.Cameras.Controls.FixedKeyControl#destroy
|
||||
* @since 3.0.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
this.camera = null;
|
||||
|
|
|
@ -15,25 +15,109 @@ var GetValue = require('../../utils/object/GetValue');
|
|||
// maxSpeed: 1.0
|
||||
// };
|
||||
|
||||
// Phaser.Cameras.Controls.Smoothed
|
||||
|
||||
var SmoothedKeyControl = new Class({
|
||||
|
||||
initialize:
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @class SmoothedKeyControl
|
||||
* @memberOf Phaser.Cameras.Controls
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {object} config - [description]
|
||||
*/
|
||||
function SmoothedKeyControl (config)
|
||||
{
|
||||
/**
|
||||
* The Camera that this Control will update.
|
||||
*
|
||||
* @property {Phaser.Cameras.Scene2D.Camera} camera
|
||||
* @default null
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.camera = GetValue(config, 'camera', null);
|
||||
|
||||
/**
|
||||
* The Key to be pressed that will move the Camera left.
|
||||
*
|
||||
* @property {Phaser.Input.Keyboard} left
|
||||
* @default null
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.left = GetValue(config, 'left', null);
|
||||
|
||||
/**
|
||||
* The Key to be pressed that will move the Camera right.
|
||||
*
|
||||
* @property {Phaser.Input.Keyboard} right
|
||||
* @default null
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.right = GetValue(config, 'right', null);
|
||||
|
||||
/**
|
||||
* The Key to be pressed that will move the Camera up.
|
||||
*
|
||||
* @property {Phaser.Input.Keyboard} up
|
||||
* @default null
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.up = GetValue(config, 'up', null);
|
||||
|
||||
/**
|
||||
* The Key to be pressed that will move the Camera down.
|
||||
*
|
||||
* @property {Phaser.Input.Keyboard} down
|
||||
* @default null
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.down = GetValue(config, 'down', null);
|
||||
|
||||
/**
|
||||
* The Key to be pressed that will zoom the Camera in.
|
||||
*
|
||||
* @property {Phaser.Input.Keyboard} zoomIn
|
||||
* @default null
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.zoomIn = GetValue(config, 'zoomIn', null);
|
||||
|
||||
/**
|
||||
* The Key to be pressed that will zoom the Camera out.
|
||||
*
|
||||
* @property {Phaser.Input.Keyboard} zoomOut
|
||||
* @default null
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.zoomOut = GetValue(config, 'zoomOut', null);
|
||||
|
||||
/**
|
||||
* The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed.
|
||||
*
|
||||
* @property {float} zoomSpeed
|
||||
* @default 0.01
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.zoomSpeed = GetValue(config, 'zoomSpeed', 0.01);
|
||||
|
||||
/**
|
||||
* The horizontal acceleration the camera will move.
|
||||
*
|
||||
* @property {float} accelX
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* The vertical acceleration the camera will move.
|
||||
*
|
||||
* @property {float} accelY
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
var accel = GetValue(config, 'acceleration', null);
|
||||
|
||||
if (typeof accel === 'number')
|
||||
|
@ -47,6 +131,21 @@ var SmoothedKeyControl = new Class({
|
|||
this.accelY = GetValue(config, 'acceleration.y', 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* The horizontal drag applied to the camera when it is moving.
|
||||
*
|
||||
* @property {float} dragX
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* The vertical drag applied to the camera when it is moving.
|
||||
*
|
||||
* @property {float} dragY
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
var drag = GetValue(config, 'drag', null);
|
||||
|
||||
if (typeof drag === 'number')
|
||||
|
@ -60,6 +159,21 @@ var SmoothedKeyControl = new Class({
|
|||
this.dragY = GetValue(config, 'drag.y', 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* The maximum horizontal speed the camera will move.
|
||||
*
|
||||
* @property {float} maxSpeedX
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* The maximum vertical speed the camera will move.
|
||||
*
|
||||
* @property {float} maxSpeedY
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
var maxSpeed = GetValue(config, 'maxSpeed', null);
|
||||
|
||||
if (typeof maxSpeed === 'number')
|
||||
|
@ -73,13 +187,53 @@ var SmoothedKeyControl = new Class({
|
|||
this.maxSpeedY = GetValue(config, 'maxSpeed.y', 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {number} _speedX
|
||||
* @private
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._speedX = 0;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {number} _speedY
|
||||
* @private
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._speedY = 0;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {number} _zoom
|
||||
* @private
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._zoom = 0;
|
||||
|
||||
/**
|
||||
* A flag controlling if the Controls will update the Camera or not.
|
||||
*
|
||||
* @property {boolean} active
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.active = (this.camera !== null);
|
||||
},
|
||||
|
||||
/**
|
||||
* Starts the Key Control running, providing it has been linked to a camera.
|
||||
*
|
||||
* @method Phaser.Cameras.Controls.SmoothedKeyControl#start
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {Phaser.Cameras.Controls.SmoothedKeyControl} This Key Control instance.
|
||||
*/
|
||||
start: function ()
|
||||
{
|
||||
this.active = (this.camera !== null);
|
||||
|
@ -87,6 +241,14 @@ var SmoothedKeyControl = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Stops this Key Control from running. Call `start` to start it again.
|
||||
*
|
||||
* @method Phaser.Cameras.Controls.SmoothedKeyControl#stop
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {Phaser.Cameras.Controls.SmoothedKeyControl} This Key Control instance.
|
||||
*/
|
||||
stop: function ()
|
||||
{
|
||||
this.active = false;
|
||||
|
@ -94,6 +256,16 @@ var SmoothedKeyControl = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Binds this Key Control to a camera.
|
||||
*
|
||||
* @method Phaser.Cameras.Controls.SmoothedKeyControl#setCamera
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The camera to bind this Key Control to.
|
||||
*
|
||||
* @return {Phaser.Cameras.Controls.SmoothedKeyControl} This Key Control instance.
|
||||
*/
|
||||
setCamera: function (camera)
|
||||
{
|
||||
this.camera = camera;
|
||||
|
@ -101,6 +273,14 @@ var SmoothedKeyControl = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Controls.SmoothedKeyControl#update
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} delta - [description]
|
||||
*/
|
||||
update: function (delta)
|
||||
{
|
||||
if (!this.active)
|
||||
|
@ -230,6 +410,12 @@ var SmoothedKeyControl = new Class({
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroys this Key Control.
|
||||
*
|
||||
* @method Phaser.Cameras.Controls.SmoothedKeyControl#destroy
|
||||
* @since 3.0.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
this.camera = null;
|
||||
|
|
|
@ -24,46 +24,196 @@ var Camera = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @class Camera
|
||||
* @memberOf Phaser.Cameras.Sprite3D
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Scene} scene - [description]
|
||||
*/
|
||||
function Camera (scene)
|
||||
{
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {Phaser.Scene} scene
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.scene = scene;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {[type]} displayList
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.displayList = scene.sys.displayList;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {[type]} updateList
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.updateList = scene.sys.updateList;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {string} name
|
||||
* @default ''
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.name = '';
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {[type]} direction
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.direction = new Vector3(0, 0, -1);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {[type]} up
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.up = new Vector3(0, 1, 0);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {[type]} position
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.position = new Vector3();
|
||||
|
||||
// The mapping from 3D size units to pixels.
|
||||
// In the default case 1 3D unit = 128 pixels. So a sprite that is
|
||||
// 256 x 128 px in size will be 2 x 1 units.
|
||||
// Change to whatever best fits your game assets.
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {[type]} pixelScale
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.pixelScale = 128;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {[type]} projection
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.projection = new Matrix4();
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {[type]} view
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.view = new Matrix4();
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {[type]} combined
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.combined = new Matrix4();
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {[type]} invProjectionView
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.invProjectionView = new Matrix4();
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {number} near
|
||||
* @default 1
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.near = 1;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {[type]} far
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.far = 100;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {[type]} ray
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.ray = {
|
||||
origin: new Vector3(),
|
||||
direction: new Vector3()
|
||||
};
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {number} viewportWidth
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.viewportWidth = 0;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {number} viewportHeight
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.viewportHeight = 0;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {boolean} billboardMatrixDirty
|
||||
* @default true
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.billboardMatrixDirty = true;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {[type]} children
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.children = new Set();
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.Camera#setPosition
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} x - [description]
|
||||
* @param {[type]} y - [description]
|
||||
* @param {[type]} z - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
setPosition: function (x, y, z)
|
||||
{
|
||||
this.position.set(x, y, z);
|
||||
|
@ -71,6 +221,16 @@ var Camera = new Class({
|
|||
return this.update();
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.Camera#setScene
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} scene - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
setScene: function (scene)
|
||||
{
|
||||
this.scene = scene;
|
||||
|
@ -78,6 +238,16 @@ var Camera = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.Camera#setPixelScale
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} value - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
setPixelScale: function (value)
|
||||
{
|
||||
this.pixelScale = value;
|
||||
|
@ -85,6 +255,16 @@ var Camera = new Class({
|
|||
return this.update();
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.Camera#add
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} sprite3D - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
add: function (sprite3D)
|
||||
{
|
||||
this.children.set(sprite3D);
|
||||
|
@ -94,6 +274,16 @@ var Camera = new Class({
|
|||
return sprite3D;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.Camera#remove
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} child - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
remove: function (child)
|
||||
{
|
||||
this.displayList.remove(child.gameObject);
|
||||
|
@ -104,6 +294,14 @@ var Camera = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.Camera#clear
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
clear: function ()
|
||||
{
|
||||
var children = this.getChildren();
|
||||
|
@ -116,11 +314,34 @@ var Camera = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.Camera#getChildren
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
getChildren: function ()
|
||||
{
|
||||
return this.children.entries;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.Camera#create
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} x - [description]
|
||||
* @param {[type]} y - [description]
|
||||
* @param {[type]} z - [description]
|
||||
* @param {[type]} key - [description]
|
||||
* @param {[type]} frame - [description]
|
||||
* @param {[type]} visible - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
create: function (x, y, z, key, frame, visible)
|
||||
{
|
||||
if (visible === undefined) { visible = true; }
|
||||
|
@ -139,6 +360,19 @@ var Camera = new Class({
|
|||
return child;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.Camera#createMultiple
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} quantity - [description]
|
||||
* @param {[type]} key - [description]
|
||||
* @param {[type]} frame - [description]
|
||||
* @param {[type]} visible - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
createMultiple: function (quantity, key, frame, visible)
|
||||
{
|
||||
if (visible === undefined) { visible = true; }
|
||||
|
@ -164,6 +398,19 @@ var Camera = new Class({
|
|||
|
||||
// Create a bunch of Sprite3D objects in a rectangle
|
||||
// size and spacing are Vec3s (or if integers are converted to vec3s)
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.Camera#createRect
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} size - [description]
|
||||
* @param {[type]} spacing - [description]
|
||||
* @param {[type]} key - [description]
|
||||
* @param {[type]} frame - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
createRect: function (size, spacing, key, frame)
|
||||
{
|
||||
if (typeof size === 'number') { size = { x: size, y: size, z: size }; }
|
||||
|
@ -197,6 +444,17 @@ var Camera = new Class({
|
|||
return sprites;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.Camera#randomSphere
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} radius - [description]
|
||||
* @param {[type]} sprites - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
randomSphere: function (radius, sprites)
|
||||
{
|
||||
if (sprites === undefined) { sprites = this.getChildren(); }
|
||||
|
@ -209,6 +467,17 @@ var Camera = new Class({
|
|||
return this.update();
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.Camera#randomCube
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} scale - [description]
|
||||
* @param {[type]} sprites - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
randomCube: function (scale, sprites)
|
||||
{
|
||||
if (sprites === undefined) { sprites = this.getChildren(); }
|
||||
|
@ -221,6 +490,17 @@ var Camera = new Class({
|
|||
return this.update();
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.Camera#translateChildren
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} vec3 - [description]
|
||||
* @param {[type]} sprites - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
translateChildren: function (vec3, sprites)
|
||||
{
|
||||
if (sprites === undefined) { sprites = this.getChildren(); }
|
||||
|
@ -233,6 +513,17 @@ var Camera = new Class({
|
|||
return this.update();
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.Camera#transformChildren
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} mat4 - [description]
|
||||
* @param {[type]} sprites - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
transformChildren: function (mat4, sprites)
|
||||
{
|
||||
if (sprites === undefined) { sprites = this.getChildren(); }
|
||||
|
@ -253,6 +544,17 @@ var Camera = new Class({
|
|||
* @param {Number} width the viewport width
|
||||
* @param {Number} height the viewport height
|
||||
*/
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.Camera#setViewport
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} width - [description]
|
||||
* @param {[type]} height - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
setViewport: function (width, height)
|
||||
{
|
||||
this.viewportWidth = width;
|
||||
|
@ -270,6 +572,18 @@ var Camera = new Class({
|
|||
* @param {[type]} vec [description]
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.Camera#translate
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} x - [description]
|
||||
* @param {[type]} y - [description]
|
||||
* @param {[type]} z - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
translate: function (x, y, z)
|
||||
{
|
||||
if (typeof x === 'object')
|
||||
|
@ -288,6 +602,18 @@ var Camera = new Class({
|
|||
return this.update();
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.Camera#lookAt
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} x - [description]
|
||||
* @param {[type]} y - [description]
|
||||
* @param {[type]} z - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
lookAt: function (x, y, z)
|
||||
{
|
||||
var dir = this.direction;
|
||||
|
@ -313,6 +639,17 @@ var Camera = new Class({
|
|||
return this.update();
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.Camera#rotate
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} radians - [description]
|
||||
* @param {[type]} axis - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
rotate: function (radians, axis)
|
||||
{
|
||||
RotateVec3(this.direction, axis, radians);
|
||||
|
@ -321,6 +658,18 @@ var Camera = new Class({
|
|||
return this.update();
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.Camera#rotateAround
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} point - [description]
|
||||
* @param {[type]} radians - [description]
|
||||
* @param {[type]} axis - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
rotateAround: function (point, radians, axis)
|
||||
{
|
||||
tmpVec3.copy(point).subtract(this.position);
|
||||
|
@ -332,6 +681,17 @@ var Camera = new Class({
|
|||
return this.update();
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.Camera#project
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} vec - [description]
|
||||
* @param {[type]} out - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
project: function (vec, out)
|
||||
{
|
||||
if (out === undefined) { out = new Vector4(); }
|
||||
|
@ -375,6 +735,17 @@ var Camera = new Class({
|
|||
return out;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.Camera#unproject
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} vec - [description]
|
||||
* @param {[type]} out - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
unproject: function (vec, out)
|
||||
{
|
||||
if (out === undefined) { out = new Vector3(); }
|
||||
|
@ -384,6 +755,17 @@ var Camera = new Class({
|
|||
return out.copy(vec).unproject(viewport, this.invProjectionView);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.Camera#getPickRay
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} x - [description]
|
||||
* @param {[type]} y - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
getPickRay: function (x, y)
|
||||
{
|
||||
var origin = this.ray.origin.set(x, y, 0);
|
||||
|
@ -400,6 +782,14 @@ var Camera = new Class({
|
|||
return this.ray;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.Camera#updateChildren
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
updateChildren: function ()
|
||||
{
|
||||
var children = this.children.entries;
|
||||
|
@ -413,11 +803,25 @@ var Camera = new Class({
|
|||
},
|
||||
|
||||
// Overriden by subclasses
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.Camera#update
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
update: function ()
|
||||
{
|
||||
return this.updateChildren();
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.Camera#updateBillboardMatrix
|
||||
* @since 3.0.0
|
||||
*/
|
||||
updateBillboardMatrix: function ()
|
||||
{
|
||||
var dir = dirvec.set(this.direction).negate();
|
||||
|
@ -470,6 +874,18 @@ var Camera = new Class({
|
|||
* @param {Vector2} out the result, scaled x and y dimensions in 3D space
|
||||
* @return {Vector2} returns the out parameter, or a new Vector2 if none was given
|
||||
*/
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.Camera#getPointSize
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} vec - [description]
|
||||
* @param {[type]} size - [description]
|
||||
* @param {[type]} out - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
getPointSize: function (vec, size, out)
|
||||
{
|
||||
if (out === undefined) { out = new Vector2(); }
|
||||
|
@ -511,6 +927,12 @@ var Camera = new Class({
|
|||
return out.set(w, h);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.Camera#destroy
|
||||
* @since 3.0.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
this.children.clear();
|
||||
|
@ -519,6 +941,16 @@ var Camera = new Class({
|
|||
this.children = undefined;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.Camera#setX
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} value - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
setX: function (value)
|
||||
{
|
||||
this.position.x = value;
|
||||
|
@ -526,6 +958,16 @@ var Camera = new Class({
|
|||
return this.update();
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.Camera#setY
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} value - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
setY: function (value)
|
||||
{
|
||||
this.position.y = value;
|
||||
|
@ -533,6 +975,16 @@ var Camera = new Class({
|
|||
return this.update();
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.Camera#setZ
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} value - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
setZ: function (value)
|
||||
{
|
||||
this.position.z = value;
|
||||
|
|
|
@ -10,11 +10,32 @@ var CameraManager = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @class CameraManager
|
||||
* @memberOf Phaser.Cameras.Sprite3D
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Scene} scene - [description]
|
||||
*/
|
||||
function CameraManager (scene)
|
||||
{
|
||||
// The Scene that owns this plugin
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {Phaser.Scene} scene
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.scene = scene;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {[type]} systems
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.systems = scene.sys;
|
||||
|
||||
if (!scene.sys.settings.isBooted)
|
||||
|
@ -23,6 +44,12 @@ var CameraManager = new Class({
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.CameraManager#boot
|
||||
* @since 3.0.0
|
||||
*/
|
||||
boot: function ()
|
||||
{
|
||||
var eventEmitter = this.systems.events;
|
||||
|
@ -32,11 +59,34 @@ var CameraManager = new Class({
|
|||
eventEmitter.on('destroy', this.destroy, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.CameraManager#add
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} fieldOfView - [description]
|
||||
* @param {[type]} width - [description]
|
||||
* @param {[type]} height - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
add: function (fieldOfView, width, height)
|
||||
{
|
||||
return this.addPerspectiveCamera(fieldOfView, width, height);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.CameraManager#addOrthographicCamera
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} width - [description]
|
||||
* @param {[type]} height - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
addOrthographicCamera: function (width, height)
|
||||
{
|
||||
var config = this.scene.sys.game.config;
|
||||
|
@ -49,6 +99,18 @@ var CameraManager = new Class({
|
|||
return camera;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.CameraManager#addPerspectiveCamera
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} fieldOfView - [description]
|
||||
* @param {[type]} width - [description]
|
||||
* @param {[type]} height - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
addPerspectiveCamera: function (fieldOfView, width, height)
|
||||
{
|
||||
var config = this.scene.sys.game.config;
|
||||
|
@ -62,11 +124,27 @@ var CameraManager = new Class({
|
|||
return camera;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.CameraManager#destroy
|
||||
* @since 3.0.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
this.scene = undefined;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.CameraManager#getCamera
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} name - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
getCamera: function (name)
|
||||
{
|
||||
this.cameras.forEach(function (camera)
|
||||
|
@ -80,6 +158,14 @@ var CameraManager = new Class({
|
|||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.CameraManager#removeCamera
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} camera - [description]
|
||||
*/
|
||||
removeCamera: function (camera)
|
||||
{
|
||||
var cameraIndex = this.cameras.indexOf(camera);
|
||||
|
@ -96,6 +182,16 @@ var CameraManager = new Class({
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.CameraManager#render
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} renderer - [description]
|
||||
* @param {[type]} children - [description]
|
||||
* @param {[type]} interpolation - [description]
|
||||
*/
|
||||
render: function (renderer, children, interpolation)
|
||||
{
|
||||
var cameras = this.cameras;
|
||||
|
@ -110,6 +206,14 @@ var CameraManager = new Class({
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.CameraManager#resetAll
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
resetAll: function ()
|
||||
{
|
||||
while (this.cameras.length > 0)
|
||||
|
@ -122,6 +226,15 @@ var CameraManager = new Class({
|
|||
return this.main;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.CameraManager#update
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} timestep - [description]
|
||||
* @param {[type]} delta - [description]
|
||||
*/
|
||||
update: function (timestep, delta)
|
||||
{
|
||||
for (var i = 0, l = this.cameras.length; i < l; ++i)
|
||||
|
@ -130,6 +243,12 @@ var CameraManager = new Class({
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.CameraManager#shutdown
|
||||
* @since 3.0.0
|
||||
*/
|
||||
shutdown: function ()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -13,6 +13,19 @@ var OrthographicCamera = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @class OrthographicCamera
|
||||
* @extends Phaser.Cameras.Sprite3D.Camera
|
||||
* @memberOf Phaser.Cameras.Sprite3D
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Scene} scene - [description]
|
||||
* @param {integer} viewportWidth - [description]
|
||||
* @param {integer} viewportHeight - [description]
|
||||
*/
|
||||
function OrthographicCamera (scene, viewportWidth, viewportHeight)
|
||||
{
|
||||
if (viewportWidth === undefined) { viewportWidth = 0; }
|
||||
|
@ -20,16 +33,55 @@ var OrthographicCamera = new Class({
|
|||
|
||||
Camera.call(this, scene);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {integer} viewportWidth
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.viewportWidth = viewportWidth;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {integer} viewportHeight
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.viewportHeight = viewportHeight;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {float} _zoom
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._zoom = 1.0;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {number} near
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.near = 0;
|
||||
|
||||
this.update();
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.OrthographicCamera#setToOrtho
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} yDown - [description]
|
||||
* @param {[type]} viewportWidth - [description]
|
||||
* @param {[type]} viewportHeight - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
setToOrtho: function (yDown, viewportWidth, viewportHeight)
|
||||
{
|
||||
if (viewportWidth === undefined) { viewportWidth = this.viewportWidth; }
|
||||
|
@ -47,6 +99,14 @@ var OrthographicCamera = new Class({
|
|||
return this.update();
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.OrthographicCamera#update
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
update: function ()
|
||||
{
|
||||
var w = this.viewportWidth;
|
||||
|
|
|
@ -14,6 +14,20 @@ var PerspectiveCamera = new Class({
|
|||
// FOV is converted to radians automatically
|
||||
initialize:
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @class PerspectiveCamera
|
||||
* @extends Phaser.Cameras.Sprite3D.Camera
|
||||
* @memberOf Phaser.Cameras.Sprite3D
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Scene} scene - [description]
|
||||
* @param {integer} fieldOfView - [description]
|
||||
* @param {integer} viewportWidth - [description]
|
||||
* @param {integer} viewportHeight - [description]
|
||||
*/
|
||||
function PerspectiveCamera (scene, fieldOfView, viewportWidth, viewportHeight)
|
||||
{
|
||||
if (fieldOfView === undefined) { fieldOfView = 80; }
|
||||
|
@ -22,13 +36,46 @@ var PerspectiveCamera = new Class({
|
|||
|
||||
Camera.call(this, scene);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {integer} viewportWidth
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.viewportWidth = viewportWidth;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {integer} viewportHeight
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.viewportHeight = viewportHeight;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {integer} fieldOfView
|
||||
* @default 80
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.fieldOfView = fieldOfView * Math.PI / 180;
|
||||
|
||||
this.update();
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.PerspectiveCamera#setFOV
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} value - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
setFOV: function (value)
|
||||
{
|
||||
this.fieldOfView = value * Math.PI / 180;
|
||||
|
@ -36,6 +83,14 @@ var PerspectiveCamera = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Sprite3D.PerspectiveCamera#update
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
update: function ()
|
||||
{
|
||||
var aspect = this.viewportWidth / this.viewportHeight;
|
||||
|
|
|
@ -1,7 +1,17 @@
|
|||
var GetValue = require('../utils/object/GetValue');
|
||||
var Arne16 = require('./palettes/Arne16');
|
||||
var CanvasPool = require('../display/canvas/CanvasPool');
|
||||
var GetValue = require('../utils/object/GetValue');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Create.GenerateTexture
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {object} config - [description]
|
||||
*
|
||||
* @return {HTMLCanvasElement} [description]
|
||||
*/
|
||||
var GenerateTexture = function (config)
|
||||
{
|
||||
var data = GetValue(config, 'data', []);
|
||||
|
|
|
@ -1,5 +1,26 @@
|
|||
// A 16 color palette by [Arne](http://androidarts.com/palette/16pal.htm)
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @name Phaser.Create.Palettes.ARNE16
|
||||
* @description A 16 color palette by [Arne](http://androidarts.com/palette/16pal.htm)
|
||||
* @since 3.0.0
|
||||
* @type {object}
|
||||
* @property {string} 0 - Color value 1.
|
||||
* @property {string} 1 - Color value 2.
|
||||
* @property {string} 2 - Color value 3.
|
||||
* @property {string} 3 - Color value 4.
|
||||
* @property {string} 4 - Color value 5.
|
||||
* @property {string} 5 - Color value 6.
|
||||
* @property {string} 6 - Color value 7.
|
||||
* @property {string} 7 - Color value 8.
|
||||
* @property {string} 8 - Color value 9.
|
||||
* @property {string} 9 - Color value 10.
|
||||
* @property {string} A - Color value 11.
|
||||
* @property {string} B - Color value 12.
|
||||
* @property {string} C - Color value 13.
|
||||
* @property {string} D - Color value 14.
|
||||
* @property {string} E - Color value 15.
|
||||
* @property {string} F - Color value 16.
|
||||
*/
|
||||
module.exports = {
|
||||
0: '#000',
|
||||
1: '#9D9D9D',
|
||||
|
|
|
@ -1,5 +1,26 @@
|
|||
// A 16 color C64 inspired palette.
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @name Phaser.Create.Palettes.C64
|
||||
* @description A 16 color palette inspired by the Commodore 64.
|
||||
* @type {object}
|
||||
* @since 3.0.0
|
||||
* @property {string} 0 - Color value 1.
|
||||
* @property {string} 1 - Color value 2.
|
||||
* @property {string} 2 - Color value 3.
|
||||
* @property {string} 3 - Color value 4.
|
||||
* @property {string} 4 - Color value 5.
|
||||
* @property {string} 5 - Color value 6.
|
||||
* @property {string} 6 - Color value 7.
|
||||
* @property {string} 7 - Color value 8.
|
||||
* @property {string} 8 - Color value 9.
|
||||
* @property {string} 9 - Color value 10.
|
||||
* @property {string} A - Color value 11.
|
||||
* @property {string} B - Color value 12.
|
||||
* @property {string} C - Color value 13.
|
||||
* @property {string} D - Color value 14.
|
||||
* @property {string} E - Color value 15.
|
||||
* @property {string} F - Color value 16.
|
||||
*/
|
||||
module.exports = {
|
||||
0: '#000',
|
||||
1: '#fff',
|
||||
|
|
|
@ -1,5 +1,26 @@
|
|||
// A 16 color CGA inspired palette by [Arne](http://androidarts.com/palette/16pal.htm)
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @name Phaser.Create.Palettes.CGA
|
||||
* @description A 16 color CGA inspired palette by [Arne](http://androidarts.com/palette/16pal.htm)
|
||||
* @since 3.0.0
|
||||
* @type {object}
|
||||
* @property {string} 0 - Color value 1.
|
||||
* @property {string} 1 - Color value 2.
|
||||
* @property {string} 2 - Color value 3.
|
||||
* @property {string} 3 - Color value 4.
|
||||
* @property {string} 4 - Color value 5.
|
||||
* @property {string} 5 - Color value 6.
|
||||
* @property {string} 6 - Color value 7.
|
||||
* @property {string} 7 - Color value 8.
|
||||
* @property {string} 8 - Color value 9.
|
||||
* @property {string} 9 - Color value 10.
|
||||
* @property {string} A - Color value 11.
|
||||
* @property {string} B - Color value 12.
|
||||
* @property {string} C - Color value 13.
|
||||
* @property {string} D - Color value 14.
|
||||
* @property {string} E - Color value 15.
|
||||
* @property {string} F - Color value 16.
|
||||
*/
|
||||
module.exports = {
|
||||
0: '#000',
|
||||
1: '#2234d1',
|
||||
|
|
|
@ -1,5 +1,26 @@
|
|||
// A 16 color JMP palette by [Arne](http://androidarts.com/palette/16pal.htm)
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @name Phaser.Create.Palettes.JMP
|
||||
* @description A 16 color JMP palette by [Arne](http://androidarts.com/palette/16pal.htm)
|
||||
* @type {object}
|
||||
* @since 3.0.0
|
||||
* @property {string} 0 - Color value 1.
|
||||
* @property {string} 1 - Color value 2.
|
||||
* @property {string} 2 - Color value 3.
|
||||
* @property {string} 3 - Color value 4.
|
||||
* @property {string} 4 - Color value 5.
|
||||
* @property {string} 5 - Color value 6.
|
||||
* @property {string} 6 - Color value 7.
|
||||
* @property {string} 7 - Color value 8.
|
||||
* @property {string} 8 - Color value 9.
|
||||
* @property {string} 9 - Color value 10.
|
||||
* @property {string} A - Color value 11.
|
||||
* @property {string} B - Color value 12.
|
||||
* @property {string} C - Color value 13.
|
||||
* @property {string} D - Color value 14.
|
||||
* @property {string} E - Color value 15.
|
||||
* @property {string} F - Color value 16.
|
||||
*/
|
||||
module.exports = {
|
||||
0: '#000',
|
||||
1: '#191028',
|
||||
|
|
|
@ -1,5 +1,26 @@
|
|||
// A 16 color palette inspired by Japanese computers like the MSX.
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @name Phaser.Create.Palettes.MSX
|
||||
* @description A 16 color palette inspired by Japanese computers like the MSX.
|
||||
* @type {object}
|
||||
* @since 3.0.0
|
||||
* @property {string} 0 - Color value 1.
|
||||
* @property {string} 1 - Color value 2.
|
||||
* @property {string} 2 - Color value 3.
|
||||
* @property {string} 3 - Color value 4.
|
||||
* @property {string} 4 - Color value 5.
|
||||
* @property {string} 5 - Color value 6.
|
||||
* @property {string} 6 - Color value 7.
|
||||
* @property {string} 7 - Color value 8.
|
||||
* @property {string} 8 - Color value 9.
|
||||
* @property {string} 9 - Color value 10.
|
||||
* @property {string} A - Color value 11.
|
||||
* @property {string} B - Color value 12.
|
||||
* @property {string} C - Color value 13.
|
||||
* @property {string} D - Color value 14.
|
||||
* @property {string} E - Color value 15.
|
||||
* @property {string} F - Color value 16.
|
||||
*/
|
||||
module.exports = {
|
||||
0: '#000',
|
||||
1: '#191028',
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
// Phaser.Create.Palettes
|
||||
|
||||
module.exports = {
|
||||
|
||||
ARNE16: require('./Arne16'),
|
||||
|
|
|
@ -17,6 +17,20 @@ var CubicBezierCurve = new Class({
|
|||
// p1 = control point 1
|
||||
// p2 = control point 2
|
||||
// p3 = end point
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @class CubicBezierCurve
|
||||
* @extends Phaser.Curves.Curve
|
||||
* @memberOf Phaser.Curves
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} p0 - [description]
|
||||
* @param {[type]} p1 - [description]
|
||||
* @param {[type]} p2 - [description]
|
||||
* @param {[type]} p3 - [description]
|
||||
*/
|
||||
function CubicBezierCurve (p0, p1, p2, p3)
|
||||
{
|
||||
Curve.call(this, 'CubicBezierCurve');
|
||||
|
@ -29,12 +43,49 @@ var CubicBezierCurve = new Class({
|
|||
p0 = new Vector2(p0[0], p0[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {[type]} p0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.p0 = p0;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {[type]} p1
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.p1 = p1;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {[type]} p2
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.p2 = p2;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {[type]} p3
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.p3 = p3;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.CubicBezierCurve#getStartPoint
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} out - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
getStartPoint: function (out)
|
||||
{
|
||||
if (out === undefined) { out = new Vector2(); }
|
||||
|
@ -42,11 +93,32 @@ var CubicBezierCurve = new Class({
|
|||
return out.copy(this.p0);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.CubicBezierCurve#getResolution
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} divisions - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
getResolution: function (divisions)
|
||||
{
|
||||
return divisions;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.CubicBezierCurve#getPoint
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} t - [description]
|
||||
* @param {[type]} out - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
getPoint: function (t, out)
|
||||
{
|
||||
if (out === undefined) { out = new Vector2(); }
|
||||
|
@ -59,6 +131,17 @@ var CubicBezierCurve = new Class({
|
|||
return out.set(CubicBezier(t, p0.x, p1.x, p2.x, p3.x), CubicBezier(t, p0.y, p1.y, p2.y, p3.y));
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.CubicBezierCurve#draw
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} graphics - [description]
|
||||
* @param {[type]} pointsTotal - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
draw: function (graphics, pointsTotal)
|
||||
{
|
||||
if (pointsTotal === undefined) { pointsTotal = 32; }
|
||||
|
@ -79,6 +162,14 @@ var CubicBezierCurve = new Class({
|
|||
return graphics;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.CubicBezierCurve#toJSON
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
toJSON: function ()
|
||||
{
|
||||
return {
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog)
|
||||
|
||||
var Class = require('../../utils/Class');
|
||||
var FromPoints = require('../../geom/rectangle/FromPoints');
|
||||
var Rectangle = require('../../geom/rectangle/Rectangle');
|
||||
var Vector2 = require('../../math/Vector2');
|
||||
|
||||
// Our Base Curve which all other curves extend
|
||||
|
||||
var Curve = new Class({
|
||||
|
||||
initialize:
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A Base Curve class, which all other curve types extend.
|
||||
*
|
||||
* Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog)
|
||||
*
|
||||
* @class Curve
|
||||
* @memberOf Phaser.Curves
|
||||
|
@ -24,41 +22,46 @@ var Curve = new Class({
|
|||
function Curve (type)
|
||||
{
|
||||
/**
|
||||
* String based identifier
|
||||
* String based identifier for the type of curve.
|
||||
*
|
||||
* @property {string} type
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.type = type;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The default number of divisions within the curve.
|
||||
*
|
||||
* @property {integer} defaultDivisions
|
||||
* @default 5
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.defaultDivisions = 5;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* The quantity of arc length divisions within the curve.
|
||||
*
|
||||
* @property {integer} arcLengthDivisions
|
||||
* @default 100
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.arcLengthDivisions = 100;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* An array of cached arc length values.
|
||||
*
|
||||
* @property {array} cacheArcLengths
|
||||
* @default []
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.cacheArcLengths = [];
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Does the data of this curve need updating?
|
||||
*
|
||||
* @property {boolean} needsUpdate
|
||||
* @default true
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.needsUpdate = true;
|
||||
|
||||
|
@ -67,36 +70,42 @@ var Curve = new Class({
|
|||
*
|
||||
* @property {boolean} active
|
||||
* @default true
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.active = true;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A temporary calculation Vector.
|
||||
*
|
||||
* @property {Phaser.Math.Vector2} _tmpVec2A
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._tmpVec2A = new Vector2();
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* A temporary calculation Vector.
|
||||
*
|
||||
* @property {Phaser.Math.Vector2} _tmpVec2B
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._tmpVec2B = new Vector2();
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Draws this curve on the given Graphics object.
|
||||
*
|
||||
* The curve is drawn using `Graphics.strokePoints` so will be drawn at whatever the present Graphics stroke color is.
|
||||
* The Graphics object is not cleared before the draw, so the curve will appear on-top of anything else already rendered to it.
|
||||
*
|
||||
* @method Phaser.Curves.Curve#draw
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.Graphics} graphics - [description]
|
||||
* @param {integer} [pointsTotal=32] - [description]
|
||||
* @param {Phaser.GameObjects.Graphics} graphics - The Graphics instance onto which this curve will be drawn.
|
||||
* @param {integer} [pointsTotal=32] - The resolution of the curve. The higher the value the smoother it will render, at the cost of rendering performance.
|
||||
*
|
||||
* @return {Phaser.GameObjects.Graphics} [description]
|
||||
* @return {Phaser.GameObjects.Graphics} The Graphics object to which the curve was drawn.
|
||||
*/
|
||||
draw: function (graphics, pointsTotal)
|
||||
{
|
||||
|
@ -107,19 +116,22 @@ var Curve = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Returns a Rectangle where the position and dimensions match the bounds of this Curve.
|
||||
*
|
||||
* You can control the accuracy of the bounds. The value given is used to work out how many points
|
||||
* to plot across the curve. Higher values are more accurate at the cost of calculation speed.
|
||||
*
|
||||
* @method Phaser.Curves.Curve#getBounds
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Rectangle} out - [description]
|
||||
* @param {integer} [accuracy=16] - [description]
|
||||
* @param {Phaser.Geom.Rectangle} out - The Rectangle to store the bounds in. If falsey a new object will be created.
|
||||
* @param {integer} [accuracy=16] - The accuracy of the bounds calculations.
|
||||
*
|
||||
* @return {Phaser.Geom.Rectangle} [description]
|
||||
* @return {Phaser.Geom.Rectangle} A Rectangle containing the bounds values of this Curve.
|
||||
*/
|
||||
getBounds: function (out, accuracy)
|
||||
{
|
||||
if (out === undefined) { out = new Rectangle(); }
|
||||
if (!out) { out = new Rectangle(); }
|
||||
if (accuracy === undefined) { accuracy = 16; }
|
||||
|
||||
var len = this.getLength();
|
||||
|
@ -137,17 +149,16 @@ var Curve = new Class({
|
|||
return FromPoints(this.getSpacedPoints(spaced), out);
|
||||
},
|
||||
|
||||
// Return an array of points, spaced out X distance pixels apart
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Returns an array of points, spaced out X distance pixels apart.
|
||||
* The smaller the distance, the larger the array will be.
|
||||
*
|
||||
* @method Phaser.Curves.Curve#getDistancePoints
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {integer} distance - [description]
|
||||
* @param {integer} distance - The distance, in pixels, between each point along the curve.
|
||||
*
|
||||
* @return {Phaser.Geom.Point[]} [description]
|
||||
* @return {Phaser.Geom.Point[]} An Array of Point objects.
|
||||
*/
|
||||
getDistancePoints: function (distance)
|
||||
{
|
||||
|
|
|
@ -15,6 +15,24 @@ var EllipseCurve = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @class EllipseCurve
|
||||
* @extends Phaser.Curves.Curve
|
||||
* @memberOf Phaser.Curves
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} [x=0] - [description]
|
||||
* @param {number} [y=0] - [description]
|
||||
* @param {number} [xRadius=0] - [description]
|
||||
* @param {number} [yRadius=0] - [description]
|
||||
* @param {number} [startAngle=0] - [description]
|
||||
* @param {number} [endAngle=360] - [description]
|
||||
* @param {boolean} [clockwise=false] - [description]
|
||||
* @param {number} [rotation=0] - [description]
|
||||
*/
|
||||
function EllipseCurve (x, y, xRadius, yRadius, startAngle, endAngle, clockwise, rotation)
|
||||
{
|
||||
if (typeof x === 'object')
|
||||
|
@ -42,22 +60,78 @@ var EllipseCurve = new Class({
|
|||
Curve.call(this, 'EllipseCurve');
|
||||
|
||||
// Center point
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {[type]} p0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.p0 = new Vector2(x, y);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {[type]} _xRadius
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._xRadius = xRadius;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {[type]} _yRadius
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._yRadius = yRadius;
|
||||
|
||||
// Radians
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {[type]} _startAngle
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._startAngle = DegToRad(startAngle);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {[type]} _endAngle
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._endAngle = DegToRad(endAngle);
|
||||
|
||||
// Boolean (anti-clockwise direction)
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {[type]} _clockwise
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._clockwise = clockwise;
|
||||
|
||||
// The rotation of the arc
|
||||
this._rotation = DegToRad(rotation);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.EllipseCurve#getStartPoint
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} out - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
getStartPoint: function (out)
|
||||
{
|
||||
if (out === undefined) { out = new Vector2(); }
|
||||
|
@ -65,11 +139,32 @@ var EllipseCurve = new Class({
|
|||
return this.getPoint(0, out);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.EllipseCurve#getResolution
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} divisions - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
getResolution: function (divisions)
|
||||
{
|
||||
return divisions * 2;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.EllipseCurve#getPoint
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} t - [description]
|
||||
* @param {[type]} out - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
getPoint: function (t, out)
|
||||
{
|
||||
if (out === undefined) { out = new Vector2(); }
|
||||
|
@ -133,6 +228,16 @@ var EllipseCurve = new Class({
|
|||
return out.set(x, y);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.EllipseCurve#setXRadius
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} value - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
setXRadius: function (value)
|
||||
{
|
||||
this.xRadius = value;
|
||||
|
@ -140,6 +245,16 @@ var EllipseCurve = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.EllipseCurve#setYRadius
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} value - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
setYRadius: function (value)
|
||||
{
|
||||
this.yRadius = value;
|
||||
|
@ -147,6 +262,16 @@ var EllipseCurve = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.EllipseCurve#setWidth
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} value - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
setWidth: function (value)
|
||||
{
|
||||
this.xRadius = value * 2;
|
||||
|
@ -154,6 +279,16 @@ var EllipseCurve = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.EllipseCurve#setHeight
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} value - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
setHeight: function (value)
|
||||
{
|
||||
this.yRadius = value * 2;
|
||||
|
@ -161,6 +296,16 @@ var EllipseCurve = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.EllipseCurve#setStartAngle
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} value - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
setStartAngle: function (value)
|
||||
{
|
||||
this.startAngle = value;
|
||||
|
@ -168,6 +313,16 @@ var EllipseCurve = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.EllipseCurve#setEndAngle
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} value - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
setEndAngle: function (value)
|
||||
{
|
||||
this.endAngle = value;
|
||||
|
@ -175,6 +330,16 @@ var EllipseCurve = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.EllipseCurve#setClockwise
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} value - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
setClockwise: function (value)
|
||||
{
|
||||
this.clockwise = value;
|
||||
|
@ -182,6 +347,16 @@ var EllipseCurve = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.EllipseCurve#setRotation
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} value - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
setRotation: function (value)
|
||||
{
|
||||
this.rotation = value;
|
||||
|
@ -301,6 +476,14 @@ var EllipseCurve = new Class({
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.EllipseCurve#toJSON
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
toJSON: function ()
|
||||
{
|
||||
return {
|
||||
|
|
|
@ -17,6 +17,18 @@ var LineCurve = new Class({
|
|||
initialize:
|
||||
|
||||
// vec2s or array
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @class LineCurve
|
||||
* @extends Phaser.Curves.Curve
|
||||
* @memberOf Phaser.Curves
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} p0 - [description]
|
||||
* @param {[type]} p1 - [description]
|
||||
*/
|
||||
function LineCurve (p0, p1)
|
||||
{
|
||||
Curve.call(this, 'LineCurve');
|
||||
|
@ -27,10 +39,33 @@ var LineCurve = new Class({
|
|||
p0 = new Vector2(p0[0], p0[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {[type]} p0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.p0 = p0;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {[type]} p1
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.p1 = p1;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.LineCurve#getBounds
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} out - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
getBounds: function (out)
|
||||
{
|
||||
if (out === undefined) { out = new Rectangle(); }
|
||||
|
@ -38,6 +73,16 @@ var LineCurve = new Class({
|
|||
return FromPoints([ this.p0, this.p1 ], out);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.LineCurve#getStartPoint
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} out - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
getStartPoint: function (out)
|
||||
{
|
||||
if (out === undefined) { out = new Vector2(); }
|
||||
|
@ -45,11 +90,30 @@ var LineCurve = new Class({
|
|||
return out.copy(this.p0);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.LineCurve#getResolution
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {integer} [description]
|
||||
*/
|
||||
getResolution: function ()
|
||||
{
|
||||
return 1;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.LineCurve#getPoint
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} t - [description]
|
||||
* @param {[type]} out - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
getPoint: function (t, out)
|
||||
{
|
||||
if (out === undefined) { out = new Vector2(); }
|
||||
|
@ -65,11 +129,30 @@ var LineCurve = new Class({
|
|||
},
|
||||
|
||||
// Line curve is linear, so we can overwrite default getPointAt
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.LineCurve#getPointAt
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} u - [description]
|
||||
* @param {[type]} out - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
getPointAt: function (u, out)
|
||||
{
|
||||
return this.getPoint(u, out);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.LineCurve#getTangent
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
getTangent: function ()
|
||||
{
|
||||
var tangent = tmpVec2.copy(this.p1).subtract(this.p0);
|
||||
|
@ -78,6 +161,16 @@ var LineCurve = new Class({
|
|||
},
|
||||
|
||||
// Override default Curve.draw because this is better than calling getPoints on a line!
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.LineCurve#draw
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} graphics - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
draw: function (graphics)
|
||||
{
|
||||
graphics.lineBetween(this.p0.x, this.p0.y, this.p1.x, this.p1.y);
|
||||
|
@ -86,6 +179,14 @@ var LineCurve = new Class({
|
|||
return graphics;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.LineCurve#toJSON
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
toJSON: function ()
|
||||
{
|
||||
return {
|
||||
|
|
|
@ -5,14 +5,44 @@ var MoveTo = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @class MoveTo
|
||||
* @memberOf Phaser.Curves
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} [x] - [description]
|
||||
* @param {number} [y] - [description]
|
||||
*/
|
||||
function MoveTo (x, y)
|
||||
{
|
||||
// Skip length calcs in paths
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {boolean} active
|
||||
* @default false
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.active = false;
|
||||
|
||||
this.p0 = new Vector2(x, y);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.MoveTo#getPoint
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} t - [description]
|
||||
* @param {[type]} out - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
getPoint: function (t, out)
|
||||
{
|
||||
if (out === undefined) { out = new Vector2(); }
|
||||
|
@ -20,21 +50,56 @@ var MoveTo = new Class({
|
|||
return out.copy(this.p0);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.MoveTo#getPointAt
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} u - [description]
|
||||
* @param {[type]} out - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
getPointAt: function (u, out)
|
||||
{
|
||||
return this.getPoint(u, out);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.MoveTo#getResolution
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
getResolution: function ()
|
||||
{
|
||||
return 1;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.MoveTo#getLength
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
getLength: function ()
|
||||
{
|
||||
return 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.MoveTo#toJSON
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
toJSON: function ()
|
||||
{
|
||||
return {
|
||||
|
|
|
@ -14,23 +14,84 @@ var Path = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @class Path
|
||||
* @memberOf Phaser.Curves
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} [x=0] - [description]
|
||||
* @param {number} [y=0] - [description]
|
||||
*/
|
||||
function Path (x, y)
|
||||
{
|
||||
if (x === undefined) { x = 0; }
|
||||
if (y === undefined) { y = 0; }
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {string} name
|
||||
* @default ''
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.name = '';
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {array} curves
|
||||
* @default []
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.curves = [];
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {array} cacheLengths
|
||||
* @default []
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.cacheLengths = [];
|
||||
|
||||
// Automatically closes the path
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {boolean} autoClose
|
||||
* @default false
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.autoClose = false;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {Phaser.Math.Vector2} startPoint
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.startPoint = new Vector2();
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {Phaser.Math.Vector2} _tmpVec2A
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._tmpVec2A = new Vector2();
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {Phaser.Math.Vector2} _tmpVec2B
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._tmpVec2B = new Vector2();
|
||||
|
||||
if (typeof x === 'object')
|
||||
|
|
|
@ -13,7 +13,17 @@ var SplineCurve = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
// Array of vec2s
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @class SplineCurve
|
||||
* @extends Phaser.Curves.Curve
|
||||
* @memberOf Phaser.Curves
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Geom.Point[]} [points] - [description]
|
||||
*/
|
||||
function SplineCurve (points)
|
||||
{
|
||||
if (points === undefined) { points = []; }
|
||||
|
@ -22,11 +32,28 @@ var SplineCurve = new Class({
|
|||
|
||||
// if points is an array of numbers ...
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {Phaser.Geom.Point[]} points
|
||||
* @default []
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.points = [];
|
||||
|
||||
this.addPoints(points);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.SplineCurve#addPoints
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} points - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
addPoints: function (points)
|
||||
{
|
||||
for (var i = 0; i < points.length; i++)
|
||||
|
@ -57,6 +84,17 @@ var SplineCurve = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.SplineCurve#addPoint
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} x - [description]
|
||||
* @param {[type]} y - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
addPoint: function (x, y)
|
||||
{
|
||||
var vec = new Vector2(x, y);
|
||||
|
@ -66,6 +104,16 @@ var SplineCurve = new Class({
|
|||
return vec;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.SplineCurve#getStartPoint
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} out - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
getStartPoint: function (out)
|
||||
{
|
||||
if (out === undefined) { out = new Vector2(); }
|
||||
|
@ -73,11 +121,32 @@ var SplineCurve = new Class({
|
|||
return out.copy(this.points[0]);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.SplineCurve#getResolution
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} divisions - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
getResolution: function (divisions)
|
||||
{
|
||||
return divisions * this.points.length;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.SplineCurve#getPoint
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {[type]} t - [description]
|
||||
* @param {[type]} out - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
getPoint: function (t, out)
|
||||
{
|
||||
if (out === undefined) { out = new Vector2(); }
|
||||
|
@ -98,6 +167,14 @@ var SplineCurve = new Class({
|
|||
return out.set(CatmullRom(weight, p0.x, p1.x, p2.x, p3.x), CatmullRom(weight, p0.y, p1.y, p2.y, p3.y));
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Curves.SplineCurve#toJSON
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
toJSON: function ()
|
||||
{
|
||||
var points = [];
|
||||
|
|
|
@ -1,34 +1,36 @@
|
|||
var Browser = require('./Browser');
|
||||
|
||||
/**
|
||||
* Determines the audio playback capabilities of the device running this Phaser Game instance.
|
||||
* These values are read-only and populated during the boot sequence of the game.
|
||||
* They are then referenced by internal game systems and are available for you to access
|
||||
* via `this.sys.game.device.audio` from within any Scene.
|
||||
*
|
||||
* @namespace Phaser.Device.Audio
|
||||
* @typedef {object} DeviceAudio
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @property {boolean} audioData - Can this device play HTML Audio tags?
|
||||
* @property {boolean} dolby - Can this device play EC-3 Dolby Digital Plus files?
|
||||
* @property {boolean} m4a - Can this device can play m4a files.
|
||||
* @property {boolean} mp3 - Can this device play mp3 files?
|
||||
* @property {boolean} ogg - Can this device play ogg files?
|
||||
* @property {boolean} opus - Can this device play opus files?
|
||||
* @property {boolean} wav - Can this device play wav files?
|
||||
* @property {boolean} webAudio - Does this device have the Web Audio API?
|
||||
* @property {boolean} webm - Can this device play webm files?
|
||||
*/
|
||||
var Audio = {
|
||||
|
||||
// @property {boolean} audioData - Are Audio tags available?
|
||||
audioData: false,
|
||||
|
||||
// @property {boolean} webAudio - Is the WebAudio API available?
|
||||
webAudio: false,
|
||||
|
||||
// @property {boolean} ogg - Can this device play ogg files?
|
||||
ogg: false,
|
||||
|
||||
// @property {boolean} opus - Can this device play opus files?
|
||||
opus: false,
|
||||
|
||||
// @property {boolean} mp3 - Can this device play mp3 files?
|
||||
mp3: false,
|
||||
|
||||
// @property {boolean} wav - Can this device play wav files?
|
||||
wav: false,
|
||||
|
||||
// Can this device play m4a files?
|
||||
// @property {boolean} m4a - True if this device can play m4a files.
|
||||
dolby: false,
|
||||
m4a: false,
|
||||
|
||||
// @property {boolean} webm - Can this device play webm files?
|
||||
webm: false,
|
||||
|
||||
// @property {boolean} dolby - Can this device play EC-3 Dolby Digital Plus files?
|
||||
dolby: false
|
||||
mp3: false,
|
||||
ogg: false,
|
||||
opus: false,
|
||||
wav: false,
|
||||
webAudio: false,
|
||||
webm: false
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -1,57 +1,46 @@
|
|||
var OS = require('./OS');
|
||||
|
||||
/**
|
||||
* Determines the browser type and version running this Phaser Game instance.
|
||||
* These values are read-only and populated during the boot sequence of the game.
|
||||
* They are then referenced by internal game systems and are available for you to access
|
||||
* via `this.sys.game.device.browser` from within any Scene.
|
||||
*
|
||||
* @namespace Phaser.Device.Browser
|
||||
* @typedef {object} DeviceBrowser
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @property {boolean} chrome - Set to true if running in Chrome.
|
||||
* @property {boolean} edge - Set to true if running in Microsoft Edge browser.
|
||||
* @property {boolean} firefox - Set to true if running in Firefox.
|
||||
* @property {boolean} ie - Set to true if running in Internet Explorer 11 or less (not Edge).
|
||||
* @property {boolean} mobileSafari - Set to true if running in Mobile Safari.
|
||||
* @property {boolean} opera - Set to true if running in Opera.
|
||||
* @property {boolean} safari - Set to true if running in Safari.
|
||||
* @property {boolean} silk - Set to true if running in the Silk browser (as used on the Amazon Kindle)
|
||||
* @property {boolean} trident - Set to true if running a Trident version of Internet Explorer (IE11+)
|
||||
* @property {number} chromeVersion - If running in Chrome this will contain the major version number.
|
||||
* @property {number} firefoxVersion - If running in Firefox this will contain the major version number.
|
||||
* @property {number} ieVersion - If running in Internet Explorer this will contain the major version number. Beyond IE10 you should use Browser.trident and Browser.tridentVersion.
|
||||
* @property {number} safariVersion - If running in Safari this will contain the major version number.
|
||||
* @property {number} tridentVersion - If running in Internet Explorer 11 this will contain the major version number. See {@link http://msdn.microsoft.com/en-us/library/ie/ms537503(v=vs.85).aspx}
|
||||
*/
|
||||
var Browser = {
|
||||
|
||||
// @property {boolean} arora - Set to true if running in Arora.
|
||||
arora: false,
|
||||
|
||||
// @property {boolean} chrome - Set to true if running in Chrome.
|
||||
chrome: false,
|
||||
|
||||
// @property {number} chromeVersion - If running in Chrome this will contain the major version number.
|
||||
chromeVersion: 0,
|
||||
|
||||
// @property {boolean} epiphany - Set to true if running in Epiphany.
|
||||
epiphany: false,
|
||||
|
||||
// @property {boolean} firefox - Set to true if running in Firefox.
|
||||
firefox: false,
|
||||
|
||||
// @property {number} firefoxVersion - If running in Firefox this will contain the major version number.
|
||||
firefoxVersion: 0,
|
||||
|
||||
// @property {boolean} mobileSafari - Set to true if running in Mobile Safari.
|
||||
mobileSafari: false,
|
||||
|
||||
// @property {boolean} ie - Set to true if running in Internet Explorer.
|
||||
ie: false,
|
||||
|
||||
// @property {number} ieVersion - If running in Internet Explorer this will contain the major version number. Beyond IE10 you should use Device.trident and Device.tridentVersion.
|
||||
ieVersion: 0,
|
||||
|
||||
// @property {boolean} midori - Set to true if running in Midori.
|
||||
midori: false,
|
||||
|
||||
// @property {boolean} opera - Set to true if running in Opera.
|
||||
opera: false,
|
||||
|
||||
// @property {boolean} safari - Set to true if running in Safari.
|
||||
safari: false,
|
||||
|
||||
// @property {number} safariVersion - If running in Safari this will contain the major version number.
|
||||
safariVersion: 0,
|
||||
|
||||
// @property {boolean} trident - Set to true if running a Trident version of Internet Explorer (IE11+)
|
||||
trident: false,
|
||||
|
||||
// @property {number} tridentVersion - If running in Internet Explorer 11 this will contain the major version number. See {@link http://msdn.microsoft.com/en-us/library/ie/ms537503(v=vs.85).aspx}
|
||||
tridentVersion: 0,
|
||||
|
||||
// @property {boolean} edge - Set to true if running in Microsoft Edge browser.
|
||||
edge: false,
|
||||
|
||||
// @property {boolean} silk - Set to true if running in the Silk browser (as used on the Amazon Kindle)
|
||||
silk: false
|
||||
firefox: false,
|
||||
firefoxVersion: 0,
|
||||
ie: false,
|
||||
ieVersion: 0,
|
||||
mobileSafari: false,
|
||||
opera: false,
|
||||
safari: false,
|
||||
safariVersion: 0,
|
||||
silk: false,
|
||||
trident: false,
|
||||
tridentVersion: 0
|
||||
|
||||
};
|
||||
|
||||
|
@ -59,11 +48,7 @@ function init ()
|
|||
{
|
||||
var ua = navigator.userAgent;
|
||||
|
||||
if ((/Arora/).test(ua))
|
||||
{
|
||||
Browser.arora = true;
|
||||
}
|
||||
else if (/Edge\/\d+/.test(ua))
|
||||
if (/Edge\/\d+/.test(ua))
|
||||
{
|
||||
Browser.edge = true;
|
||||
}
|
||||
|
@ -72,10 +57,6 @@ function init ()
|
|||
Browser.chrome = true;
|
||||
Browser.chromeVersion = parseInt(RegExp.$1, 10);
|
||||
}
|
||||
else if ((/Epiphany/).test(ua))
|
||||
{
|
||||
Browser.epiphany = true;
|
||||
}
|
||||
else if ((/Firefox\D+(\d+)/).test(ua))
|
||||
{
|
||||
Browser.firefox = true;
|
||||
|
@ -90,10 +71,6 @@ function init ()
|
|||
Browser.ie = true;
|
||||
Browser.ieVersion = parseInt(RegExp.$1, 10);
|
||||
}
|
||||
else if ((/Midori/).test(ua))
|
||||
{
|
||||
Browser.midori = true;
|
||||
}
|
||||
else if ((/Opera/).test(ua))
|
||||
{
|
||||
Browser.opera = true;
|
||||
|
|
|
@ -1,10 +1,22 @@
|
|||
var CanvasPool = require('../display/canvas/CanvasPool');
|
||||
|
||||
/**
|
||||
* Determines the canvas features of the browser running this Phaser Game instance.
|
||||
* These values are read-only and populated during the boot sequence of the game.
|
||||
* They are then referenced by internal game systems and are available for you to access
|
||||
* via `this.sys.game.device.canvasFeatures` from within any Scene.
|
||||
*
|
||||
* @namespace Phaser.Device.CanvasFeatures
|
||||
* @typedef {object} DeviceCanvasFeatures
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @property {boolean} supportInverseAlpha - Set to true if the browser supports inversed alpha.
|
||||
* @property {boolean} supportNewBlendModes - Set to true if the browser supports new canvas blend modes.
|
||||
*/
|
||||
var CanvasFeatures = {
|
||||
|
||||
supportNewBlendModes: false,
|
||||
|
||||
supportInverseAlpha: false
|
||||
supportInverseAlpha: false,
|
||||
supportNewBlendModes: false
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -2,43 +2,43 @@ var OS = require('./OS');
|
|||
var Browser = require('./Browser');
|
||||
var CanvasPool = require('../display/canvas/CanvasPool');
|
||||
|
||||
/**
|
||||
* Determines the features of the browser running this Phaser Game instance.
|
||||
* These values are read-only and populated during the boot sequence of the game.
|
||||
* They are then referenced by internal game systems and are available for you to access
|
||||
* via `this.sys.game.device.features` from within any Scene.
|
||||
*
|
||||
* @namespace Phaser.Device.Features
|
||||
* @typedef {object} DeviceFeatures
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @property {?boolean} canvasBitBltShift - True if canvas supports a 'copy' bitblt onto itself when the source and destination regions overlap.
|
||||
* @property {boolean} canvas - Is canvas available?
|
||||
* @property {boolean} file - Is file available?
|
||||
* @property {boolean} fileSystem - Is fileSystem available?
|
||||
* @property {boolean} getUserMedia - Does the device support the getUserMedia API?
|
||||
* @property {boolean} littleEndian - Is the device big or little endian? (only detected if the browser supports TypedArrays)
|
||||
* @property {boolean} localStorage - Is localStorage available?
|
||||
* @property {boolean} pointerLock - Is Pointer Lock available?
|
||||
* @property {boolean} support32bit - Does the device context support 32bit pixel manipulation using array buffer views?
|
||||
* @property {boolean} vibration - Does the device support the Vibration API?
|
||||
* @property {boolean} webGL - Is webGL available?
|
||||
* @property {boolean} worker - Is worker available?
|
||||
*/
|
||||
var Features = {
|
||||
|
||||
// @property {boolean} canvas - Is canvas available?
|
||||
canvas: false,
|
||||
|
||||
// @property {?boolean} canvasBitBltShift - True if canvas supports a 'copy' bitblt onto itself when the source and destination regions overlap.
|
||||
canvasBitBltShift: null,
|
||||
|
||||
// @property {boolean} webGL - Is webGL available?
|
||||
webGL: false,
|
||||
|
||||
// @property {boolean} file - Is file available?
|
||||
file: false,
|
||||
|
||||
// @property {boolean} fileSystem - Is fileSystem available?
|
||||
fileSystem: false,
|
||||
|
||||
// @property {boolean} localStorage - Is localStorage available?
|
||||
localStorage: false,
|
||||
|
||||
// @property {boolean} worker - Is worker available?
|
||||
worker: false,
|
||||
|
||||
// @property {boolean} pointerLock - Is Pointer Lock available?
|
||||
pointerLock: false,
|
||||
|
||||
// @property {boolean} vibration - Does the device support the Vibration API?
|
||||
vibration: false,
|
||||
|
||||
// @property {boolean} getUserMedia - Does the device support the getUserMedia API?
|
||||
getUserMedia: true,
|
||||
|
||||
// @property {boolean} littleEndian - Is the device big or little endian? (only detected if the browser supports TypedArrays)
|
||||
littleEndian: false,
|
||||
|
||||
// @property {boolean} support32bit - Does the device context support 32bit pixel manipulation using array buffer views?
|
||||
support32bit: false
|
||||
localStorage: false,
|
||||
pointerLock: false,
|
||||
support32bit: false,
|
||||
vibration: false,
|
||||
webGL: false,
|
||||
worker: false
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -1,16 +1,24 @@
|
|||
/**
|
||||
* Determines the full screen support of the browser running this Phaser Game instance.
|
||||
* These values are read-only and populated during the boot sequence of the game.
|
||||
* They are then referenced by internal game systems and are available for you to access
|
||||
* via `this.sys.game.device.fullscreen` from within any Scene.
|
||||
*
|
||||
* @namespace Phaser.Device.Fullscreen
|
||||
* @typedef {object} DeviceFullscreen
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @property {boolean} available - Does the browser support the Full Screen API?
|
||||
* @property {boolean} keyboard - Does the browser support access to the Keyboard during Full Screen mode?
|
||||
* @property {string} cancel - If the browser supports the Full Screen API this holds the call you need to use to cancel it.
|
||||
* @property {string} request - If the browser supports the Full Screen API this holds the call you need to use to activate it.
|
||||
*/
|
||||
var Fullscreen = {
|
||||
|
||||
// @property {boolean} available - Does the browser support the Full Screen API?
|
||||
available: false,
|
||||
|
||||
// @property {string} request - If the browser supports the Full Screen API this holds the call you need to use to activate it.
|
||||
request: '',
|
||||
|
||||
// @property {string} cancel - If the browser supports the Full Screen API this holds the call you need to use to cancel it.
|
||||
cancel: '',
|
||||
|
||||
// @property {boolean} keyboard - Does the browser support access to the Keyboard during Full Screen mode?
|
||||
keyboard: false
|
||||
keyboard: false,
|
||||
request: ''
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -1,19 +1,27 @@
|
|||
var OS = require('./OS');
|
||||
var Browser = require('./Browser');
|
||||
|
||||
/**
|
||||
* Determines the input support of the browser running this Phaser Game instance.
|
||||
* These values are read-only and populated during the boot sequence of the game.
|
||||
* They are then referenced by internal game systems and are available for you to access
|
||||
* via `this.sys.game.device.input` from within any Scene.
|
||||
*
|
||||
* @namespace Phaser.Device.Input
|
||||
* @typedef {object} DeviceInput
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @property {?string} wheelType - The newest type of Wheel/Scroll event supported: 'wheel', 'mousewheel', 'DOMMouseScroll'
|
||||
* @property {boolean} gamepads - Is navigator.getGamepads available?
|
||||
* @property {boolean} mspointer - Is mspointer available?
|
||||
* @property {boolean} touch - Is touch available?
|
||||
*/
|
||||
var Input = {
|
||||
|
||||
// @property {boolean} touch - Is touch available?
|
||||
touch: false,
|
||||
|
||||
// @property {boolean} mspointer - Is mspointer available?
|
||||
gamepads: false,
|
||||
mspointer: false,
|
||||
|
||||
// @property {?string} wheelType - The newest type of Wheel/Scroll event supported: 'wheel', 'mousewheel', 'DOMMouseScroll'
|
||||
wheelEvent: null,
|
||||
|
||||
// @property {boolean} gamepads - Is navigator.getGamepads available?
|
||||
gamepads: false
|
||||
touch: false,
|
||||
wheelEvent: null
|
||||
|
||||
};
|
||||
|
||||
|
|
121
src/device/OS.js
121
src/device/OS.js
|
@ -1,73 +1,60 @@
|
|||
/**
|
||||
* Determines the operating system of the device running this Phaser Game instance.
|
||||
* These values are read-only and populated during the boot sequence of the game.
|
||||
* They are then referenced by internal game systems and are available for you to access
|
||||
* via `this.sys.game.device.os` from within any Scene.
|
||||
*
|
||||
* @namespace Phaser.Device.OS
|
||||
* @typedef {object} DeviceOS
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @property {boolean} android - Is running on android?
|
||||
* @property {boolean} chromeOS - Is running on chromeOS?
|
||||
* @property {boolean} cocoonJS - Is the game running under CocoonJS?
|
||||
* @property {boolean} cocoonJSApp - Is this game running with CocoonJS.App?
|
||||
* @property {boolean} cordova - Is the game running under Apache Cordova?
|
||||
* @property {boolean} crosswalk - Is the game running under the Intel Crosswalk XDK?
|
||||
* @property {boolean} desktop - Is running on a desktop?
|
||||
* @property {boolean} ejecta - Is the game running under Ejecta?
|
||||
* @property {boolean} electron - Is the game running under GitHub Electron?
|
||||
* @property {boolean} iOS - Is running on iOS?
|
||||
* @property {boolean} iPad - Is running on iPad?
|
||||
* @property {boolean} iPhone - Is running on iPhone?
|
||||
* @property {boolean} kindle - Is running on an Amazon Kindle?
|
||||
* @property {boolean} linux - Is running on linux?
|
||||
* @property {boolean} macOS - Is running on macOS?
|
||||
* @property {boolean} node - Is the game running under Node.js?
|
||||
* @property {boolean} nodeWebkit - Is the game running under Node-Webkit?
|
||||
* @property {boolean} webApp - Set to true if running as a WebApp, i.e. within a WebView
|
||||
* @property {boolean} windows - Is running on windows?
|
||||
* @property {boolean} windowsPhone - Is running on a Windows Phone?
|
||||
* @property {number} iOSVersion - If running in iOS this will contain the major version number.
|
||||
* @property {number} pixelRatio - PixelRatio of the host device?
|
||||
*/
|
||||
var OS = {
|
||||
|
||||
// @property {boolean} desktop - Is running on a desktop?
|
||||
desktop: false,
|
||||
|
||||
// @property {boolean} webApp - Set to true if running as a WebApp, i.e. within a WebView
|
||||
webApp: false,
|
||||
|
||||
// @property {boolean} iOS - Is running on iOS?
|
||||
iOS: false,
|
||||
|
||||
// @property {number} iOSVersion - If running in iOS this will contain the major version number.
|
||||
iOSVersion: 0,
|
||||
|
||||
// @property {boolean} iPhone - Is running on iPhone?
|
||||
iPhone: false,
|
||||
|
||||
// @property {boolean} iPad - Is running on iPad?
|
||||
iPad: false,
|
||||
|
||||
// @property {boolean} cocoonJS - Is the game running under CocoonJS?
|
||||
cocoonJS: false,
|
||||
|
||||
// @property {boolean} cocoonJSApp - Is this game running with CocoonJS.App?
|
||||
cocoonJSApp: false,
|
||||
|
||||
// @property {boolean} cordova - Is the game running under Apache Cordova?
|
||||
cordova: false,
|
||||
|
||||
// @property {boolean} node - Is the game running under Node.js?
|
||||
node: false,
|
||||
|
||||
// @property {boolean} nodeWebkit - Is the game running under Node-Webkit?
|
||||
nodeWebkit: false,
|
||||
|
||||
// @property {boolean} electron - Is the game running under GitHub Electron?
|
||||
electron: false,
|
||||
|
||||
// @property {boolean} ejecta - Is the game running under Ejecta?
|
||||
ejecta: false,
|
||||
|
||||
// @property {boolean} crosswalk - Is the game running under the Intel Crosswalk XDK?
|
||||
crosswalk: false,
|
||||
|
||||
// @property {boolean} android - Is running on android?
|
||||
android: false,
|
||||
|
||||
// @property {boolean} chromeOS - Is running on chromeOS?
|
||||
chromeOS: false,
|
||||
|
||||
// @property {boolean} linux - Is running on linux?
|
||||
linux: false,
|
||||
|
||||
// @property {boolean} macOS - Is running on macOS?
|
||||
macOS: false,
|
||||
|
||||
// @property {boolean} windows - Is running on windows?
|
||||
windows: false,
|
||||
|
||||
// @property {boolean} windowsPhone - Is running on a Windows Phone?
|
||||
windowsPhone: false,
|
||||
|
||||
// @property {boolean} vita - Is running on a PlayStation Vita?
|
||||
vita: false,
|
||||
|
||||
// @property {boolean} kindle - Is running on an Amazon Kindle?
|
||||
cocoonJS: false,
|
||||
cocoonJSApp: false,
|
||||
cordova: false,
|
||||
crosswalk: false,
|
||||
desktop: false,
|
||||
ejecta: false,
|
||||
electron: false,
|
||||
iOS: false,
|
||||
iOSVersion: 0,
|
||||
iPad: false,
|
||||
iPhone: false,
|
||||
kindle: false,
|
||||
|
||||
// @property {number} pixelRatio - PixelRatio of the host device?
|
||||
pixelRatio: 1
|
||||
linux: false,
|
||||
macOS: false,
|
||||
node: false,
|
||||
nodeWebkit: false,
|
||||
pixelRatio: 1,
|
||||
webApp: false,
|
||||
windows: false,
|
||||
windowsPhone: false
|
||||
|
||||
};
|
||||
|
||||
|
@ -108,10 +95,6 @@ function init ()
|
|||
{
|
||||
OS.chromeOS = true;
|
||||
}
|
||||
else if ((/Playstation Vita/).test(ua))
|
||||
{
|
||||
OS.vita = true;
|
||||
}
|
||||
|
||||
if (/Windows Phone/i.test(ua) || (/IEMobile/i).test(ua))
|
||||
{
|
||||
|
|
|
@ -1,23 +1,28 @@
|
|||
|
||||
/**
|
||||
* Determines the video support of the browser running this Phaser Game instance.
|
||||
* These values are read-only and populated during the boot sequence of the game.
|
||||
* They are then referenced by internal game systems and are available for you to access
|
||||
* via `this.sys.game.device.video` from within any Scene.
|
||||
*
|
||||
* @namespace Phaser.Device.Video
|
||||
* @typedef {object} DeviceVideo
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @property {boolean} h264Video - Can this device play h264 mp4 video files?
|
||||
* @property {boolean} hlsVideo - Can this device play hls video files?
|
||||
* @property {boolean} mp4Video - Can this device play h264 mp4 video files?
|
||||
* @property {boolean} oggVideo - Can this device play ogg video files?
|
||||
* @property {boolean} vp9Video - Can this device play vp9 video files?
|
||||
* @property {boolean} webmVideo - Can this device play webm video files?
|
||||
*/
|
||||
var Video = {
|
||||
|
||||
// @property {boolean} oggVideo - Can this device play ogg video files?
|
||||
oggVideo: false,
|
||||
|
||||
// @property {boolean} h264Video - Can this device play h264 mp4 video files?
|
||||
h264Video: false,
|
||||
|
||||
// @property {boolean} mp4Video - Can this device play h264 mp4 video files?
|
||||
hlsVideo: false,
|
||||
mp4Video: false,
|
||||
|
||||
// @property {boolean} webmVideo - Can this device play webm video files?
|
||||
webmVideo: false,
|
||||
|
||||
// @property {boolean} vp9Video - Can this device play vp9 video files?
|
||||
oggVideo: false,
|
||||
vp9Video: false,
|
||||
|
||||
// @property {boolean} hlsVideo - Can this device play hls video files?
|
||||
hlsVideo: false
|
||||
webmVideo: false
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -3,26 +3,17 @@
|
|||
// Which means all instances of Phaser Games can share it,
|
||||
// without having to re-poll the device all over again
|
||||
|
||||
var OS = require('./OS');
|
||||
var Browser = require('./Browser');
|
||||
var Features = require('./Features');
|
||||
var Input = require('./Input');
|
||||
var Audio = require('./Audio');
|
||||
var Video = require('./Video');
|
||||
var Fullscreen = require('./Fullscreen');
|
||||
var CanvasFeatures = require('./CanvasFeatures');
|
||||
|
||||
// Phaser.Device
|
||||
|
||||
module.exports = {
|
||||
|
||||
OS: OS,
|
||||
Browser: Browser,
|
||||
Features: Features,
|
||||
Input: Input,
|
||||
Audio: Audio,
|
||||
Video: Video,
|
||||
Fullscreen: Fullscreen,
|
||||
CanvasFeatures: CanvasFeatures
|
||||
os: require('./OS'),
|
||||
browser: require('./Browser'),
|
||||
features: require('./Features'),
|
||||
input: require('./Input'),
|
||||
audio: require('./Audio'),
|
||||
video: require('./Video'),
|
||||
fullscreen: require('./Fullscreen'),
|
||||
canvasFeatures: require('./CanvasFeatures')
|
||||
|
||||
};
|
||||
|
|
|
@ -3,6 +3,8 @@ var ALIGN_CONST = {
|
|||
/**
|
||||
* A constant representing a top-left alignment or position.
|
||||
* @constant
|
||||
* @name Phaser.Display.Align.TOP_LEFT
|
||||
* @since 3.0.0
|
||||
* @type {integer}
|
||||
*/
|
||||
TOP_LEFT: 0,
|
||||
|
@ -10,6 +12,8 @@ var ALIGN_CONST = {
|
|||
/**
|
||||
* A constant representing a top-center alignment or position.
|
||||
* @constant
|
||||
* @name Phaser.Display.Align.TOP_CENTER
|
||||
* @since 3.0.0
|
||||
* @type {integer}
|
||||
*/
|
||||
TOP_CENTER: 1,
|
||||
|
@ -17,6 +21,8 @@ var ALIGN_CONST = {
|
|||
/**
|
||||
* A constant representing a top-right alignment or position.
|
||||
* @constant
|
||||
* @name Phaser.Display.Align.TOP_RIGHT
|
||||
* @since 3.0.0
|
||||
* @type {integer}
|
||||
*/
|
||||
TOP_RIGHT: 2,
|
||||
|
@ -24,6 +30,8 @@ var ALIGN_CONST = {
|
|||
/**
|
||||
* A constant representing a left-top alignment or position.
|
||||
* @constant
|
||||
* @name Phaser.Display.Align.LEFT_TOP
|
||||
* @since 3.0.0
|
||||
* @type {integer}
|
||||
*/
|
||||
LEFT_TOP: 3,
|
||||
|
@ -31,6 +39,8 @@ var ALIGN_CONST = {
|
|||
/**
|
||||
* A constant representing a left-center alignment or position.
|
||||
* @constant
|
||||
* @name Phaser.Display.Align.LEFT_CENTER
|
||||
* @since 3.0.0
|
||||
* @type {integer}
|
||||
*/
|
||||
LEFT_CENTER: 4,
|
||||
|
@ -38,6 +48,8 @@ var ALIGN_CONST = {
|
|||
/**
|
||||
* A constant representing a left-bottom alignment or position.
|
||||
* @constant
|
||||
* @name Phaser.Display.Align.LEFT_BOTTOM
|
||||
* @since 3.0.0
|
||||
* @type {integer}
|
||||
*/
|
||||
LEFT_BOTTOM: 5,
|
||||
|
@ -45,6 +57,8 @@ var ALIGN_CONST = {
|
|||
/**
|
||||
* A constant representing a center alignment or position.
|
||||
* @constant
|
||||
* @name Phaser.Display.Align.CENTER
|
||||
* @since 3.0.0
|
||||
* @type {integer}
|
||||
*/
|
||||
CENTER: 6,
|
||||
|
@ -52,6 +66,8 @@ var ALIGN_CONST = {
|
|||
/**
|
||||
* A constant representing a right-top alignment or position.
|
||||
* @constant
|
||||
* @name Phaser.Display.Align.RIGHT_TOP
|
||||
* @since 3.0.0
|
||||
* @type {integer}
|
||||
*/
|
||||
RIGHT_TOP: 7,
|
||||
|
@ -59,6 +75,8 @@ var ALIGN_CONST = {
|
|||
/**
|
||||
* A constant representing a right-center alignment or position.
|
||||
* @constant
|
||||
* @name Phaser.Display.Align.RIGHT_CENTER
|
||||
* @since 3.0.0
|
||||
* @type {integer}
|
||||
*/
|
||||
RIGHT_CENTER: 8,
|
||||
|
@ -66,6 +84,8 @@ var ALIGN_CONST = {
|
|||
/**
|
||||
* A constant representing a right-bottom alignment or position.
|
||||
* @constant
|
||||
* @name Phaser.Display.Align.RIGHT_BOTTOM
|
||||
* @since 3.0.0
|
||||
* @type {integer}
|
||||
*/
|
||||
RIGHT_BOTTOM: 9,
|
||||
|
@ -73,6 +93,8 @@ var ALIGN_CONST = {
|
|||
/**
|
||||
* A constant representing a bottom-left alignment or position.
|
||||
* @constant
|
||||
* @name Phaser.Display.Align.BOTTOM_LEFT
|
||||
* @since 3.0.0
|
||||
* @type {integer}
|
||||
*/
|
||||
BOTTOM_LEFT: 10,
|
||||
|
@ -80,6 +102,8 @@ var ALIGN_CONST = {
|
|||
/**
|
||||
* A constant representing a bottom-center alignment or position.
|
||||
* @constant
|
||||
* @name Phaser.Display.Align.BOTTOM_CENTER
|
||||
* @since 3.0.0
|
||||
* @type {integer}
|
||||
*/
|
||||
BOTTOM_CENTER: 11,
|
||||
|
@ -87,6 +111,8 @@ var ALIGN_CONST = {
|
|||
/**
|
||||
* A constant representing a bottom-right alignment or position.
|
||||
* @constant
|
||||
* @name Phaser.Display.Align.BOTTOM_RIGHT
|
||||
* @since 3.0.0
|
||||
* @type {integer}
|
||||
*/
|
||||
BOTTOM_RIGHT: 12
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
var GetCenterX = require('../../bounds/GetCenterX');
|
||||
var GetBottom = require('../../bounds/GetBottom');
|
||||
var SetCenterX = require('../../bounds/SetCenterX');
|
||||
var GetCenterX = require('../../bounds/GetCenterX');
|
||||
var SetBottom = require('../../bounds/SetBottom');
|
||||
var SetCenterX = require('../../bounds/SetCenterX');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Takes given Game Object and aligns it so that it is positioned in the bottom center of the other.
|
||||
*
|
||||
* @function Phaser.Display.Align.In.BottomCenter
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} container - [description]
|
||||
* @param {number} [offsetX] - [description]
|
||||
* @param {number} [offsetY] - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned.
|
||||
* @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on.
|
||||
* @param {number} [offsetX=0] - Optional horizontal offset from the position.
|
||||
* @param {number} [offsetY=0] - Optional vertical offset from the position.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that was aligned.
|
||||
*/
|
||||
var BottomCenter = function (gameObject, container, offsetX, offsetY)
|
||||
var BottomCenter = function (gameObject, alignIn, offsetX, offsetY)
|
||||
{
|
||||
if (offsetX === undefined) { offsetX = 0; }
|
||||
if (offsetY === undefined) { offsetY = 0; }
|
||||
|
||||
SetCenterX(gameObject, GetCenterX(container) + offsetX);
|
||||
SetBottom(gameObject, GetBottom(container) + offsetY);
|
||||
SetCenterX(gameObject, GetCenterX(alignIn) + offsetX);
|
||||
SetBottom(gameObject, GetBottom(alignIn) + offsetY);
|
||||
|
||||
return gameObject;
|
||||
};
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
var GetLeft = require('../../bounds/GetLeft');
|
||||
var GetBottom = require('../../bounds/GetBottom');
|
||||
var SetLeft = require('../../bounds/SetLeft');
|
||||
var GetLeft = require('../../bounds/GetLeft');
|
||||
var SetBottom = require('../../bounds/SetBottom');
|
||||
var SetLeft = require('../../bounds/SetLeft');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Takes given Game Object and aligns it so that it is positioned in the bottom left of the other.
|
||||
*
|
||||
* @function Phaser.Display.Align.In.BottomLeft
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} container - [description]
|
||||
* @param {number} [offsetX] - [description]
|
||||
* @param {number} [offsetY] - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned.
|
||||
* @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on.
|
||||
* @param {number} [offsetX=0] - Optional horizontal offset from the position.
|
||||
* @param {number} [offsetY=0] - Optional vertical offset from the position.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that was aligned.
|
||||
*/
|
||||
var BottomLeft = function (gameObject, container, offsetX, offsetY)
|
||||
var BottomLeft = function (gameObject, alignIn, offsetX, offsetY)
|
||||
{
|
||||
if (offsetX === undefined) { offsetX = 0; }
|
||||
if (offsetY === undefined) { offsetY = 0; }
|
||||
|
||||
SetLeft(gameObject, GetLeft(container) - offsetX);
|
||||
SetBottom(gameObject, GetBottom(container) + offsetY);
|
||||
SetLeft(gameObject, GetLeft(alignIn) - offsetX);
|
||||
SetBottom(gameObject, GetBottom(alignIn) + offsetY);
|
||||
|
||||
return gameObject;
|
||||
};
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
var GetRight = require('../../bounds/GetRight');
|
||||
var GetBottom = require('../../bounds/GetBottom');
|
||||
var SetRight = require('../../bounds/SetRight');
|
||||
var GetRight = require('../../bounds/GetRight');
|
||||
var SetBottom = require('../../bounds/SetBottom');
|
||||
var SetRight = require('../../bounds/SetRight');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Takes given Game Object and aligns it so that it is positioned in the bottom right of the other.
|
||||
*
|
||||
* @function Phaser.Display.Align.In.BottomRight
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} container - [description]
|
||||
* @param {number} [offsetX] - [description]
|
||||
* @param {number} [offsetY] - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned.
|
||||
* @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on.
|
||||
* @param {number} [offsetX=0] - Optional horizontal offset from the position.
|
||||
* @param {number} [offsetY=0] - Optional vertical offset from the position.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that was aligned.
|
||||
*/
|
||||
var BottomRight = function (gameObject, container, offsetX, offsetY)
|
||||
var BottomRight = function (gameObject, alignIn, offsetX, offsetY)
|
||||
{
|
||||
if (offsetX === undefined) { offsetX = 0; }
|
||||
if (offsetY === undefined) { offsetY = 0; }
|
||||
|
||||
SetRight(gameObject, GetRight(container) + offsetX);
|
||||
SetBottom(gameObject, GetBottom(container) + offsetY);
|
||||
SetRight(gameObject, GetRight(alignIn) + offsetX);
|
||||
SetBottom(gameObject, GetBottom(alignIn) + offsetY);
|
||||
|
||||
return gameObject;
|
||||
};
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
var CenterOn = require('../../bounds/CenterOn');
|
||||
var GetCenterX = require('../../bounds/GetCenterX');
|
||||
var GetCenterY = require('../../bounds/GetCenterY');
|
||||
var CenterOn = require('../../bounds/CenterOn');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Takes given Game Object and aligns it so that it is positioned in the center of the other.
|
||||
*
|
||||
* @function Phaser.Display.Align.In.Center
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} container - [description]
|
||||
* @param {number} [offsetX=0] - [description]
|
||||
* @param {number} [offsetY=0] - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned.
|
||||
* @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on.
|
||||
* @param {number} [offsetX=0] - Optional horizontal offset from the position.
|
||||
* @param {number} [offsetY=0] - Optional vertical offset from the position.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that was aligned.
|
||||
*/
|
||||
var Center = function (gameObject, container, offsetX, offsetY)
|
||||
var Center = function (gameObject, alignIn, offsetX, offsetY)
|
||||
{
|
||||
if (offsetX === undefined) { offsetX = 0; }
|
||||
if (offsetY === undefined) { offsetY = 0; }
|
||||
|
||||
CenterOn(gameObject, GetCenterX(container) + offsetX, GetCenterY(container) + offsetY);
|
||||
CenterOn(gameObject, GetCenterX(alignIn) + offsetX, GetCenterY(alignIn) + offsetY);
|
||||
|
||||
return gameObject;
|
||||
};
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
var GetLeft = require('../../bounds/GetLeft');
|
||||
var GetCenterY = require('../../bounds/GetCenterY');
|
||||
var SetLeft = require('../../bounds/SetLeft');
|
||||
var GetLeft = require('../../bounds/GetLeft');
|
||||
var SetCenterY = require('../../bounds/SetCenterY');
|
||||
var SetLeft = require('../../bounds/SetLeft');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Takes given Game Object and aligns it so that it is positioned in the left center of the other.
|
||||
*
|
||||
* @function Phaser.Display.Align.In.LeftCenter
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} container - [description]
|
||||
* @param {number} [offsetX=0] - [description]
|
||||
* @param {number} [offsetY=0] - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned.
|
||||
* @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on.
|
||||
* @param {number} [offsetX=0] - Optional horizontal offset from the position.
|
||||
* @param {number} [offsetY=0] - Optional vertical offset from the position.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that was aligned.
|
||||
*/
|
||||
var LeftCenter = function (gameObject, container, offsetX, offsetY)
|
||||
var LeftCenter = function (gameObject, alignIn, offsetX, offsetY)
|
||||
{
|
||||
if (offsetX === undefined) { offsetX = 0; }
|
||||
if (offsetY === undefined) { offsetY = 0; }
|
||||
|
||||
SetLeft(gameObject, GetLeft(container) - offsetX);
|
||||
SetCenterY(gameObject, GetCenterY(container) + offsetY);
|
||||
SetLeft(gameObject, GetLeft(alignIn) - offsetX);
|
||||
SetCenterY(gameObject, GetCenterY(alignIn) + offsetY);
|
||||
|
||||
return gameObject;
|
||||
};
|
||||
|
|
|
@ -12,11 +12,24 @@ AlignInMap[ALIGN_CONST.TOP_CENTER] = require('./TopCenter');
|
|||
AlignInMap[ALIGN_CONST.TOP_LEFT] = require('./TopLeft');
|
||||
AlignInMap[ALIGN_CONST.TOP_RIGHT] = require('./TopRight');
|
||||
|
||||
// Phaser.Display.Align.In.QuickSet
|
||||
|
||||
var QuickSet = function (child, container, position, offsetX, offsetY)
|
||||
/**
|
||||
* Takes given Game Object and aligns it so that it is positioned relative to the other.
|
||||
* The alignment used is based on the `position` argument, which is an `ALIGN_CONST` value, such as `LEFT_CENTER` or `TOP_RIGHT`.
|
||||
*
|
||||
* @function Phaser.Display.Align.In.QuickSet
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} child - The Game Object that will be positioned.
|
||||
* @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on.
|
||||
* @param {integer} position - The position to align the Game Object with. This is an align constant, such as `ALIGN_CONST.LEFT_CENTER`.
|
||||
* @param {number} [offsetX=0] - Optional horizontal offset from the position.
|
||||
* @param {number} [offsetY=0] - Optional vertical offset from the position.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that was aligned.
|
||||
*/
|
||||
var QuickSet = function (child, alignIn, position, offsetX, offsetY)
|
||||
{
|
||||
return AlignInMap[position](child, container, offsetX, offsetY);
|
||||
return AlignInMap[position](child, alignIn, offsetX, offsetY);
|
||||
};
|
||||
|
||||
module.exports = QuickSet;
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
var GetRight = require('../../bounds/GetRight');
|
||||
var GetCenterY = require('../../bounds/GetCenterY');
|
||||
var SetRight = require('../../bounds/SetRight');
|
||||
var GetRight = require('../../bounds/GetRight');
|
||||
var SetCenterY = require('../../bounds/SetCenterY');
|
||||
var SetRight = require('../../bounds/SetRight');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Takes given Game Object and aligns it so that it is positioned in the right center of the other.
|
||||
*
|
||||
* @function Phaser.Display.Align.In.RightCenter
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} container - [description]
|
||||
* @param {number} [offsetX=0] - [description]
|
||||
* @param {number} [offsetY=0] - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned.
|
||||
* @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on.
|
||||
* @param {number} [offsetX=0] - Optional horizontal offset from the position.
|
||||
* @param {number} [offsetY=0] - Optional vertical offset from the position.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that was aligned.
|
||||
*/
|
||||
var RightCenter = function (gameObject, container, offsetX, offsetY)
|
||||
var RightCenter = function (gameObject, alignIn, offsetX, offsetY)
|
||||
{
|
||||
if (offsetX === undefined) { offsetX = 0; }
|
||||
if (offsetY === undefined) { offsetY = 0; }
|
||||
|
||||
SetRight(gameObject, GetRight(container) + offsetX);
|
||||
SetCenterY(gameObject, GetCenterY(container) + offsetY);
|
||||
SetRight(gameObject, GetRight(alignIn) + offsetX);
|
||||
SetCenterY(gameObject, GetCenterY(alignIn) + offsetY);
|
||||
|
||||
return gameObject;
|
||||
};
|
||||
|
|
|
@ -4,25 +4,25 @@ var SetCenterX = require('../../bounds/SetCenterX');
|
|||
var SetTop = require('../../bounds/SetTop');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Takes given Game Object and aligns it so that it is positioned in the top center of the other.
|
||||
*
|
||||
* @function Phaser.Display.Align.In.TopCenter
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} container - [description]
|
||||
* @param {number} [offsetX=0] - [description]
|
||||
* @param {number} [offsetY=0] - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned.
|
||||
* @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on.
|
||||
* @param {number} [offsetX=0] - Optional horizontal offset from the position.
|
||||
* @param {number} [offsetY=0] - Optional vertical offset from the position.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that was aligned.
|
||||
*/
|
||||
var TopCenter = function (gameObject, container, offsetX, offsetY)
|
||||
var TopCenter = function (gameObject, alignIn, offsetX, offsetY)
|
||||
{
|
||||
if (offsetX === undefined) { offsetX = 0; }
|
||||
if (offsetY === undefined) { offsetY = 0; }
|
||||
|
||||
SetCenterX(gameObject, GetCenterX(container) + offsetX);
|
||||
SetTop(gameObject, GetTop(container) - offsetY);
|
||||
SetCenterX(gameObject, GetCenterX(alignIn) + offsetX);
|
||||
SetTop(gameObject, GetTop(alignIn) - offsetY);
|
||||
|
||||
return gameObject;
|
||||
};
|
||||
|
|
|
@ -4,25 +4,25 @@ var SetLeft = require('../../bounds/SetLeft');
|
|||
var SetTop = require('../../bounds/SetTop');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Takes given Game Object and aligns it so that it is positioned in the top left of the other.
|
||||
*
|
||||
* @function Phaser.Display.Align.In.TopLeft
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} container - [description]
|
||||
* @param {number} [offsetX=0] - [description]
|
||||
* @param {number} [offsetY=0] - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned.
|
||||
* @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on.
|
||||
* @param {number} [offsetX=0] - Optional horizontal offset from the position.
|
||||
* @param {number} [offsetY=0] - Optional vertical offset from the position.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that was aligned.
|
||||
*/
|
||||
var TopLeft = function (gameObject, container, offsetX, offsetY)
|
||||
var TopLeft = function (gameObject, alignIn, offsetX, offsetY)
|
||||
{
|
||||
if (offsetX === undefined) { offsetX = 0; }
|
||||
if (offsetY === undefined) { offsetY = 0; }
|
||||
|
||||
SetLeft(gameObject, GetLeft(container) - offsetX);
|
||||
SetTop(gameObject, GetTop(container) - offsetY);
|
||||
SetLeft(gameObject, GetLeft(alignIn) - offsetX);
|
||||
SetTop(gameObject, GetTop(alignIn) - offsetY);
|
||||
|
||||
return gameObject;
|
||||
};
|
||||
|
|
|
@ -4,25 +4,25 @@ var SetRight = require('../../bounds/SetRight');
|
|||
var SetTop = require('../../bounds/SetTop');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Takes given Game Object and aligns it so that it is positioned in the top right of the other.
|
||||
*
|
||||
* @function Phaser.Display.Align.In.TopRight
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} container - [description]
|
||||
* @param {number} [offsetX=0] - [description]
|
||||
* @param {number} [offsetY=0] - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned.
|
||||
* @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on.
|
||||
* @param {number} [offsetX=0] - Optional horizontal offset from the position.
|
||||
* @param {number} [offsetY=0] - Optional vertical offset from the position.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that was aligned.
|
||||
*/
|
||||
var TopRight = function (gameObject, container, offsetX, offsetY)
|
||||
var TopRight = function (gameObject, alignIn, offsetX, offsetY)
|
||||
{
|
||||
if (offsetX === undefined) { offsetX = 0; }
|
||||
if (offsetY === undefined) { offsetY = 0; }
|
||||
|
||||
SetRight(gameObject, GetRight(container) + offsetX);
|
||||
SetTop(gameObject, GetTop(container) - offsetY);
|
||||
SetRight(gameObject, GetRight(alignIn) + offsetX);
|
||||
SetTop(gameObject, GetTop(alignIn) - offsetY);
|
||||
|
||||
return gameObject;
|
||||
};
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
var GetCenterX = require('../../bounds/GetCenterX');
|
||||
var GetBottom = require('../../bounds/GetBottom');
|
||||
var GetCenterX = require('../../bounds/GetCenterX');
|
||||
var SetCenterX = require('../../bounds/SetCenterX');
|
||||
var SetTop = require('../../bounds/SetTop');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Takes given Game Object and aligns it so that it is positioned next to the bottom center position of the other.
|
||||
*
|
||||
* @function Phaser.Display.Align.To.BottomCenter
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} container - [description]
|
||||
* @param {number} [offsetX=0] - [description]
|
||||
* @param {number} [offsetY=0] - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned.
|
||||
* @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on.
|
||||
* @param {number} [offsetX=0] - Optional horizontal offset from the position.
|
||||
* @param {number} [offsetY=0] - Optional vertical offset from the position.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that was aligned.
|
||||
*/
|
||||
var BottomCenter = function (gameObject, parent, offsetX, offsetY)
|
||||
var BottomCenter = function (gameObject, alignTo, offsetX, offsetY)
|
||||
{
|
||||
if (offsetX === undefined) { offsetX = 0; }
|
||||
if (offsetY === undefined) { offsetY = 0; }
|
||||
|
||||
SetCenterX(gameObject, GetCenterX(parent) + offsetX);
|
||||
SetTop(gameObject, GetBottom(parent) + offsetY);
|
||||
SetCenterX(gameObject, GetCenterX(alignTo) + offsetX);
|
||||
SetTop(gameObject, GetBottom(alignTo) + offsetY);
|
||||
|
||||
return gameObject;
|
||||
};
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
var GetLeft = require('../../bounds/GetLeft');
|
||||
var GetBottom = require('../../bounds/GetBottom');
|
||||
var GetLeft = require('../../bounds/GetLeft');
|
||||
var SetLeft = require('../../bounds/SetLeft');
|
||||
var SetTop = require('../../bounds/SetTop');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Takes given Game Object and aligns it so that it is positioned next to the bottom left position of the other.
|
||||
*
|
||||
* @function Phaser.Display.Align.To.BottomLeft
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} container - [description]
|
||||
* @param {number} [offsetX=0] - [description]
|
||||
* @param {number} [offsetY=0] - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned.
|
||||
* @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on.
|
||||
* @param {number} [offsetX=0] - Optional horizontal offset from the position.
|
||||
* @param {number} [offsetY=0] - Optional vertical offset from the position.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that was aligned.
|
||||
*/
|
||||
var BottomLeft = function (gameObject, parent, offsetX, offsetY)
|
||||
var BottomLeft = function (gameObject, alignTo, offsetX, offsetY)
|
||||
{
|
||||
if (offsetX === undefined) { offsetX = 0; }
|
||||
if (offsetY === undefined) { offsetY = 0; }
|
||||
|
||||
SetLeft(gameObject, GetLeft(parent) - offsetX);
|
||||
SetTop(gameObject, GetBottom(parent) + offsetY);
|
||||
SetLeft(gameObject, GetLeft(alignTo) - offsetX);
|
||||
SetTop(gameObject, GetBottom(alignTo) + offsetY);
|
||||
|
||||
return gameObject;
|
||||
};
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
var GetRight = require('../../bounds/GetRight');
|
||||
var GetBottom = require('../../bounds/GetBottom');
|
||||
var GetRight = require('../../bounds/GetRight');
|
||||
var SetRight = require('../../bounds/SetRight');
|
||||
var SetTop = require('../../bounds/SetTop');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Takes given Game Object and aligns it so that it is positioned next to the bottom right position of the other.
|
||||
*
|
||||
* @function Phaser.Display.Align.To.BottomRight
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} container - [description]
|
||||
* @param {number} [offsetX=0] - [description]
|
||||
* @param {number} [offsetY=0] - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned.
|
||||
* @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on.
|
||||
* @param {number} [offsetX=0] - Optional horizontal offset from the position.
|
||||
* @param {number} [offsetY=0] - Optional vertical offset from the position.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that was aligned.
|
||||
*/
|
||||
var BottomRight = function (gameObject, parent, offsetX, offsetY)
|
||||
var BottomRight = function (gameObject, alignTo, offsetX, offsetY)
|
||||
{
|
||||
if (offsetX === undefined) { offsetX = 0; }
|
||||
if (offsetY === undefined) { offsetY = 0; }
|
||||
|
||||
SetRight(gameObject, GetRight(parent) + offsetX);
|
||||
SetTop(gameObject, GetBottom(parent) + offsetY);
|
||||
SetRight(gameObject, GetRight(alignTo) + offsetX);
|
||||
SetTop(gameObject, GetBottom(alignTo) + offsetY);
|
||||
|
||||
return gameObject;
|
||||
};
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
var GetLeft = require('../../bounds/GetLeft');
|
||||
var GetBottom = require('../../bounds/GetBottom');
|
||||
var SetRight = require('../../bounds/SetRight');
|
||||
var GetLeft = require('../../bounds/GetLeft');
|
||||
var SetBottom = require('../../bounds/SetBottom');
|
||||
var SetRight = require('../../bounds/SetRight');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Takes given Game Object and aligns it so that it is positioned next to the left bottom position of the other.
|
||||
*
|
||||
* @function Phaser.Display.Align.To.LeftBottom
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} container - [description]
|
||||
* @param {number} [offsetX=0] - [description]
|
||||
* @param {number} [offsetY=0] - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned.
|
||||
* @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on.
|
||||
* @param {number} [offsetX=0] - Optional horizontal offset from the position.
|
||||
* @param {number} [offsetY=0] - Optional vertical offset from the position.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that was aligned.
|
||||
*/
|
||||
var LeftBottom = function (gameObject, parent, offsetX, offsetY)
|
||||
var LeftBottom = function (gameObject, alignTo, offsetX, offsetY)
|
||||
{
|
||||
if (offsetX === undefined) { offsetX = 0; }
|
||||
if (offsetY === undefined) { offsetY = 0; }
|
||||
|
||||
SetRight(gameObject, GetLeft(parent) - offsetX);
|
||||
SetBottom(gameObject, GetBottom(parent) + offsetY);
|
||||
SetRight(gameObject, GetLeft(alignTo) - offsetX);
|
||||
SetBottom(gameObject, GetBottom(alignTo) + offsetY);
|
||||
|
||||
return gameObject;
|
||||
};
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
var GetLeft = require('../../bounds/GetLeft');
|
||||
var GetCenterY = require('../../bounds/GetCenterY');
|
||||
var SetRight = require('../../bounds/SetRight');
|
||||
var GetLeft = require('../../bounds/GetLeft');
|
||||
var SetCenterY = require('../../bounds/SetCenterY');
|
||||
var SetRight = require('../../bounds/SetRight');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Takes given Game Object and aligns it so that it is positioned next to the left center position of the other.
|
||||
*
|
||||
* @function Phaser.Display.Align.To.LeftCenter
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} container - [description]
|
||||
* @param {number} [offsetX=0] - [description]
|
||||
* @param {number} [offsetY=0] - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned.
|
||||
* @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on.
|
||||
* @param {number} [offsetX=0] - Optional horizontal offset from the position.
|
||||
* @param {number} [offsetY=0] - Optional vertical offset from the position.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that was aligned.
|
||||
*/
|
||||
var LeftCenter = function (gameObject, parent, offsetX, offsetY)
|
||||
var LeftCenter = function (gameObject, alignTo, offsetX, offsetY)
|
||||
{
|
||||
if (offsetX === undefined) { offsetX = 0; }
|
||||
if (offsetY === undefined) { offsetY = 0; }
|
||||
|
||||
SetRight(gameObject, GetLeft(parent) - offsetX);
|
||||
SetCenterY(gameObject, GetCenterY(parent) + offsetY);
|
||||
SetRight(gameObject, GetLeft(alignTo) - offsetX);
|
||||
SetCenterY(gameObject, GetCenterY(alignTo) + offsetY);
|
||||
|
||||
return gameObject;
|
||||
};
|
||||
|
|
|
@ -4,25 +4,25 @@ var SetRight = require('../../bounds/SetRight');
|
|||
var SetTop = require('../../bounds/SetTop');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Takes given Game Object and aligns it so that it is positioned next to the left top position of the other.
|
||||
*
|
||||
* @function Phaser.Display.Align.To.LeftTop
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} container - [description]
|
||||
* @param {number} [offsetX=0] - [description]
|
||||
* @param {number} [offsetY=0] - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned.
|
||||
* @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on.
|
||||
* @param {number} [offsetX=0] - Optional horizontal offset from the position.
|
||||
* @param {number} [offsetY=0] - Optional vertical offset from the position.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that was aligned.
|
||||
*/
|
||||
var LeftTop = function (gameObject, parent, offsetX, offsetY)
|
||||
var LeftTop = function (gameObject, alignTo, offsetX, offsetY)
|
||||
{
|
||||
if (offsetX === undefined) { offsetX = 0; }
|
||||
if (offsetY === undefined) { offsetY = 0; }
|
||||
|
||||
SetRight(gameObject, GetLeft(parent) - offsetX);
|
||||
SetTop(gameObject, GetTop(parent) - offsetY);
|
||||
SetRight(gameObject, GetLeft(alignTo) - offsetX);
|
||||
SetTop(gameObject, GetTop(alignTo) - offsetY);
|
||||
|
||||
return gameObject;
|
||||
};
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
var GetRight = require('../../bounds/GetRight');
|
||||
var GetBottom = require('../../bounds/GetBottom');
|
||||
var SetLeft = require('../../bounds/SetLeft');
|
||||
var GetRight = require('../../bounds/GetRight');
|
||||
var SetBottom = require('../../bounds/SetBottom');
|
||||
var SetLeft = require('../../bounds/SetLeft');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Takes given Game Object and aligns it so that it is positioned next to the right bottom position of the other.
|
||||
*
|
||||
* @function Phaser.Display.Align.To.RightBottom
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} container - [description]
|
||||
* @param {number} [offsetX=0] - [description]
|
||||
* @param {number} [offsetY=0] - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned.
|
||||
* @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on.
|
||||
* @param {number} [offsetX=0] - Optional horizontal offset from the position.
|
||||
* @param {number} [offsetY=0] - Optional vertical offset from the position.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that was aligned.
|
||||
*/
|
||||
var RightBottom = function (gameObject, parent, offsetX, offsetY)
|
||||
var RightBottom = function (gameObject, alignTo, offsetX, offsetY)
|
||||
{
|
||||
if (offsetX === undefined) { offsetX = 0; }
|
||||
if (offsetY === undefined) { offsetY = 0; }
|
||||
|
||||
SetLeft(gameObject, GetRight(parent) + offsetX);
|
||||
SetBottom(gameObject, GetBottom(parent) + offsetY);
|
||||
SetLeft(gameObject, GetRight(alignTo) + offsetX);
|
||||
SetBottom(gameObject, GetBottom(alignTo) + offsetY);
|
||||
|
||||
return gameObject;
|
||||
};
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
var GetRight = require('../../bounds/GetRight');
|
||||
var GetCenterY = require('../../bounds/GetCenterY');
|
||||
var SetLeft = require('../../bounds/SetLeft');
|
||||
var GetRight = require('../../bounds/GetRight');
|
||||
var SetCenterY = require('../../bounds/SetCenterY');
|
||||
var SetLeft = require('../../bounds/SetLeft');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Takes given Game Object and aligns it so that it is positioned next to the right center position of the other.
|
||||
*
|
||||
* @function Phaser.Display.Align.To.RightTop
|
||||
* @function Phaser.Display.Align.To.RightCenter
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} container - [description]
|
||||
* @param {number} [offsetX=0] - [description]
|
||||
* @param {number} [offsetY=0] - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned.
|
||||
* @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on.
|
||||
* @param {number} [offsetX=0] - Optional horizontal offset from the position.
|
||||
* @param {number} [offsetY=0] - Optional vertical offset from the position.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that was aligned.
|
||||
*/
|
||||
var RightTop = function (gameObject, parent, offsetX, offsetY)
|
||||
var RightCenter = function (gameObject, alignTo, offsetX, offsetY)
|
||||
{
|
||||
if (offsetX === undefined) { offsetX = 0; }
|
||||
if (offsetY === undefined) { offsetY = 0; }
|
||||
|
||||
SetLeft(gameObject, GetRight(parent) + offsetX);
|
||||
SetCenterY(gameObject, GetCenterY(parent) + offsetY);
|
||||
SetLeft(gameObject, GetRight(alignTo) + offsetX);
|
||||
SetCenterY(gameObject, GetCenterY(alignTo) + offsetY);
|
||||
|
||||
return gameObject;
|
||||
};
|
||||
|
||||
module.exports = RightTop;
|
||||
module.exports = RightCenter;
|
||||
|
|
|
@ -4,25 +4,25 @@ var SetLeft = require('../../bounds/SetLeft');
|
|||
var SetTop = require('../../bounds/SetTop');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Takes given Game Object and aligns it so that it is positioned next to the right top position of the other.
|
||||
*
|
||||
* @function Phaser.Display.Align.To.RightTop
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} container - [description]
|
||||
* @param {number} [offsetX=0] - [description]
|
||||
* @param {number} [offsetY=0] - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned.
|
||||
* @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on.
|
||||
* @param {number} [offsetX=0] - Optional horizontal offset from the position.
|
||||
* @param {number} [offsetY=0] - Optional vertical offset from the position.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that was aligned.
|
||||
*/
|
||||
var RightTop = function (gameObject, parent, offsetX, offsetY)
|
||||
var RightTop = function (gameObject, alignTo, offsetX, offsetY)
|
||||
{
|
||||
if (offsetX === undefined) { offsetX = 0; }
|
||||
if (offsetY === undefined) { offsetY = 0; }
|
||||
|
||||
SetLeft(gameObject, GetRight(parent) + offsetX);
|
||||
SetTop(gameObject, GetTop(parent) - offsetY);
|
||||
SetLeft(gameObject, GetRight(alignTo) + offsetX);
|
||||
SetTop(gameObject, GetTop(alignTo) - offsetY);
|
||||
|
||||
return gameObject;
|
||||
};
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
var GetCenterX = require('../../bounds/GetCenterX');
|
||||
var GetTop = require('../../bounds/GetTop');
|
||||
var SetCenterX = require('../../bounds/SetCenterX');
|
||||
var SetBottom = require('../../bounds/SetBottom');
|
||||
var SetCenterX = require('../../bounds/SetCenterX');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Takes given Game Object and aligns it so that it is positioned next to the top center position of the other.
|
||||
*
|
||||
* @function Phaser.Display.Align.To.TopCenter
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} container - [description]
|
||||
* @param {number} [offsetX=0] - [description]
|
||||
* @param {number} [offsetY=0] - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned.
|
||||
* @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on.
|
||||
* @param {number} [offsetX=0] - Optional horizontal offset from the position.
|
||||
* @param {number} [offsetY=0] - Optional vertical offset from the position.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that was aligned.
|
||||
*/
|
||||
var TopCenter = function (gameObject, parent, offsetX, offsetY)
|
||||
var TopCenter = function (gameObject, alignTo, offsetX, offsetY)
|
||||
{
|
||||
if (offsetX === undefined) { offsetX = 0; }
|
||||
if (offsetY === undefined) { offsetY = 0; }
|
||||
|
||||
SetCenterX(gameObject, GetCenterX(parent) + offsetX);
|
||||
SetBottom(gameObject, GetTop(parent) - offsetY);
|
||||
SetCenterX(gameObject, GetCenterX(alignTo) + offsetX);
|
||||
SetBottom(gameObject, GetTop(alignTo) - offsetY);
|
||||
|
||||
return gameObject;
|
||||
};
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
var GetLeft = require('../../bounds/GetLeft');
|
||||
var GetTop = require('../../bounds/GetTop');
|
||||
var SetLeft = require('../../bounds/SetLeft');
|
||||
var SetBottom = require('../../bounds/SetBottom');
|
||||
var SetLeft = require('../../bounds/SetLeft');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Takes given Game Object and aligns it so that it is positioned next to the top left position of the other.
|
||||
*
|
||||
* @function Phaser.Display.Align.To.TopLeft
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} container - [description]
|
||||
* @param {number} [offsetX=0] - [description]
|
||||
* @param {number} [offsetY=0] - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned.
|
||||
* @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on.
|
||||
* @param {number} [offsetX=0] - Optional horizontal offset from the position.
|
||||
* @param {number} [offsetY=0] - Optional vertical offset from the position.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that was aligned.
|
||||
*/
|
||||
var TopLeft = function (gameObject, parent, offsetX, offsetY)
|
||||
var TopLeft = function (gameObject, alignTo, offsetX, offsetY)
|
||||
{
|
||||
if (offsetX === undefined) { offsetX = 0; }
|
||||
if (offsetY === undefined) { offsetY = 0; }
|
||||
|
||||
SetLeft(gameObject, GetLeft(parent) - offsetX);
|
||||
SetBottom(gameObject, GetTop(parent) - offsetY);
|
||||
SetLeft(gameObject, GetLeft(alignTo) - offsetX);
|
||||
SetBottom(gameObject, GetTop(alignTo) - offsetY);
|
||||
|
||||
return gameObject;
|
||||
};
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
var GetRight = require('../../bounds/GetRight');
|
||||
var GetTop = require('../../bounds/GetTop');
|
||||
var SetRight = require('../../bounds/SetRight');
|
||||
var SetBottom = require('../../bounds/SetBottom');
|
||||
var SetRight = require('../../bounds/SetRight');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Takes given Game Object and aligns it so that it is positioned next to the top right position of the other.
|
||||
*
|
||||
* @function Phaser.Display.Align.To.TopRight
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} container - [description]
|
||||
* @param {number} [offsetX=0] - [description]
|
||||
* @param {number} [offsetY=0] - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned.
|
||||
* @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on.
|
||||
* @param {number} [offsetX=0] - Optional horizontal offset from the position.
|
||||
* @param {number} [offsetY=0] - Optional vertical offset from the position.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that was aligned.
|
||||
*/
|
||||
var TopRight = function (gameObject, parent, offsetX, offsetY)
|
||||
var TopRight = function (gameObject, alignTo, offsetX, offsetY)
|
||||
{
|
||||
if (offsetX === undefined) { offsetX = 0; }
|
||||
if (offsetY === undefined) { offsetY = 0; }
|
||||
|
||||
SetRight(gameObject, GetRight(parent) + offsetX);
|
||||
SetBottom(gameObject, GetTop(parent) - offsetY);
|
||||
SetRight(gameObject, GetRight(alignTo) + offsetX);
|
||||
SetBottom(gameObject, GetTop(alignTo) - offsetY);
|
||||
|
||||
return gameObject;
|
||||
};
|
||||
|
|
|
@ -2,23 +2,16 @@ var SetCenterX = require('./SetCenterX');
|
|||
var SetCenterY = require('./SetCenterY');
|
||||
|
||||
/**
|
||||
* The center x coordinate of the Game Object.
|
||||
* This is the same as `(x - offsetX) + (width / 2)`.
|
||||
*
|
||||
* @property {number} centerX
|
||||
*/
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Positions the Game Object so that it is centered on the given coordinates.
|
||||
*
|
||||
* @function Phaser.Display.Bounds.CenterOn
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {number} x - [description]
|
||||
* @param {number} y - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned.
|
||||
* @param {number} x - The horizontal coordinate to position the Game Object on.
|
||||
* @param {number} y - The vertical coordinate to position the Game Object on.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that was positioned.
|
||||
*/
|
||||
var CenterOn = function (gameObject, x, y)
|
||||
{
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/**
|
||||
* [description]
|
||||
* Returns the bottom coordinate from the bounds of the Game Object.
|
||||
*
|
||||
* @function Phaser.Display.Bounds.GetBottom
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from.
|
||||
*
|
||||
* @return {number} [description]
|
||||
* @return {number} The bottom coordinate of the bounds of the Game Object.
|
||||
*/
|
||||
var GetBottom = function (gameObject)
|
||||
{
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/**
|
||||
* [description]
|
||||
* Returns the center x coordinate from the bounds of the Game Object.
|
||||
*
|
||||
* @function Phaser.Display.Bounds.GetCenterX
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from.
|
||||
*
|
||||
* @return {number} [description]
|
||||
* @return {number} The center x coordinate of the bounds of the Game Object.
|
||||
*/
|
||||
var GetCenterX = function (gameObject)
|
||||
{
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/**
|
||||
* [description]
|
||||
* Returns the center y coordinate from the bounds of the Game Object.
|
||||
*
|
||||
* @function Phaser.Display.Bounds.GetCenterY
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from.
|
||||
*
|
||||
* @return {number} [description]
|
||||
* @return {number} The center y coordinate of the bounds of the Game Object.
|
||||
*/
|
||||
var GetCenterY = function (gameObject)
|
||||
{
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/**
|
||||
* [description]
|
||||
* Returns the left coordinate from the bounds of the Game Object.
|
||||
*
|
||||
* @function Phaser.Display.Bounds.GetLeft
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from.
|
||||
*
|
||||
* @return {number} [description]
|
||||
* @return {number} The left coordinate of the bounds of the Game Object.
|
||||
*/
|
||||
var GetLeft = function (gameObject)
|
||||
{
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
/**
|
||||
* The amount the Game Object is visually offset from its x coordinate.
|
||||
* This is the same as `width * origin.x`.
|
||||
* It will only be > 0 if origin.x is not equal to zero.
|
||||
*
|
||||
* @property {number} offsetX
|
||||
* @readOnly
|
||||
*/
|
||||
|
||||
* Returns the amount the Game Object is visually offset from its x coordinate.
|
||||
* This is the same as `width * origin.x`.
|
||||
* This value will only be > 0 if `origin.x` is not equal to zero.
|
||||
*
|
||||
* @function Phaser.Display.Bounds.GetOffsetX
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from.
|
||||
*
|
||||
* @return {number} The horizontal offset of the Game Object.
|
||||
*/
|
||||
var GetOffsetX = function (gameObject)
|
||||
{
|
||||
return gameObject.width * gameObject.originX;
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
/**
|
||||
* The amount the Game Object is visually offset from its x coordinate.
|
||||
* This is the same as `width * origin.x`.
|
||||
* It will only be > 0 if origin.x is not equal to zero.
|
||||
*
|
||||
* @property {number} offsetX
|
||||
* @readOnly
|
||||
*/
|
||||
|
||||
* Returns the amount the Game Object is visually offset from its y coordinate.
|
||||
* This is the same as `width * origin.y`.
|
||||
* This value will only be > 0 if `origin.y` is not equal to zero.
|
||||
*
|
||||
* @function Phaser.Display.Bounds.GetOffsetY
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from.
|
||||
*
|
||||
* @return {number} The vertical offset of the Game Object.
|
||||
*/
|
||||
var GetOffsetY = function (gameObject)
|
||||
{
|
||||
return gameObject.height * gameObject.originY;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/**
|
||||
* [description]
|
||||
* Returns the right coordinate from the bounds of the Game Object.
|
||||
*
|
||||
* @function Phaser.Display.Bounds.GetRight
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from.
|
||||
*
|
||||
* @return {number} [description]
|
||||
* @return {number} The right coordinate of the bounds of the Game Object.
|
||||
*/
|
||||
var GetRight = function (gameObject)
|
||||
{
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/**
|
||||
* [description]
|
||||
* Returns the top coordinate from the bounds of the Game Object.
|
||||
*
|
||||
* @function Phaser.Display.Bounds.GetTop
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from.
|
||||
*
|
||||
* @return {number} [description]
|
||||
* @return {number} The top coordinate of the bounds of the Game Object.
|
||||
*/
|
||||
var GetTop = function (gameObject)
|
||||
{
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
/**
|
||||
* [description]
|
||||
* Positions the Game Object so that the bottom of its bounds aligns with the given coordinate.
|
||||
*
|
||||
* @function Phaser.Display.Bounds.SetBottom
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {number} value - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned.
|
||||
* @param {number} value - The coordinate to position the Game Object bounds on.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that was positioned.
|
||||
*/
|
||||
var SetBottom = function (gameObject, value)
|
||||
{
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
/**
|
||||
* [description]
|
||||
* Positions the Game Object so that the center top of its bounds aligns with the given coordinate.
|
||||
*
|
||||
* @function Phaser.Display.Bounds.SetCenterX
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {number} x - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned.
|
||||
* @param {number} x - The coordinate to position the Game Object bounds on.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that was positioned.
|
||||
*/
|
||||
var SetCenterX = function (gameObject, x)
|
||||
{
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
/**
|
||||
* [description]
|
||||
* Positions the Game Object so that the center top of its bounds aligns with the given coordinate.
|
||||
*
|
||||
* @function Phaser.Display.Bounds.SetCenterY
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {number} y - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned.
|
||||
* @param {number} y - The coordinate to position the Game Object bounds on.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that was positioned.
|
||||
*/
|
||||
var SetCenterY = function (gameObject, y)
|
||||
{
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
/**
|
||||
* [description]
|
||||
* Positions the Game Object so that the left of its bounds aligns with the given coordinate.
|
||||
*
|
||||
* @function Phaser.Display.Bounds.SetLeft
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {number} value - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned.
|
||||
* @param {number} value - The coordinate to position the Game Object bounds on.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that was positioned.
|
||||
*/
|
||||
var SetLeft = function (gameObject, value)
|
||||
{
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
/**
|
||||
* [description]
|
||||
* Positions the Game Object so that the left of its bounds aligns with the given coordinate.
|
||||
*
|
||||
* @function Phaser.Display.Bounds.SetRight
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {number} value - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned.
|
||||
* @param {number} value - The coordinate to position the Game Object bounds on.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that was positioned.
|
||||
*/
|
||||
var SetRight = function (gameObject, value)
|
||||
{
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
/**
|
||||
* [description]
|
||||
* Positions the Game Object so that the top of its bounds aligns with the given coordinate.
|
||||
*
|
||||
* @function Phaser.Display.Bounds.SetTop
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
||||
* @param {number} value - [description]
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned.
|
||||
* @param {number} value - The coordinate to position the Game Object bounds on.
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject} [description]
|
||||
* @return {Phaser.GameObjects.GameObject} The Game Object that was positioned.
|
||||
*/
|
||||
var SetTop = function (gameObject, value)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,19 @@
|
|||
/**
|
||||
* @module Phaser.Display.Canvas.CanvasInterpolation
|
||||
* @since 3.0.0
|
||||
*/
|
||||
var CanvasInterpolation = {
|
||||
|
||||
// Sets the CSS image-rendering property on the given canvas to be 'crisp' (aka 'optimize contrast' on webkit).
|
||||
// Note that if this doesn't given the desired result then see the setSmoothingEnabled.
|
||||
/**
|
||||
* Sets the CSS image-rendering property on the given canvas to be 'crisp' (aka 'optimize contrast' on webkit).
|
||||
*
|
||||
* @function setCrisp
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {HTMLCanvasElement} canvas - The canvas object to have the style set on.
|
||||
*
|
||||
* @return {HTMLCanvasElement} The canvas.
|
||||
*/
|
||||
setCrisp: function (canvas)
|
||||
{
|
||||
var types = [ 'optimizeSpeed', 'crisp-edges', '-moz-crisp-edges', '-webkit-optimize-contrast', 'optimize-contrast', 'pixelated' ];
|
||||
|
@ -16,8 +28,16 @@ var CanvasInterpolation = {
|
|||
return canvas;
|
||||
},
|
||||
|
||||
// Sets the CSS image-rendering property on the given canvas to be 'bicubic' (aka 'auto').
|
||||
// Note that if this doesn't given the desired result then see the CanvasUtils.setSmoothingEnabled method.
|
||||
/**
|
||||
* Sets the CSS image-rendering property on the given canvas to be 'bicubic' (aka 'auto').
|
||||
*
|
||||
* @function setBicubic
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {HTMLCanvasElement} canvas - The canvas object to have the style set on.
|
||||
*
|
||||
* @return {HTMLCanvasElement} The canvas.
|
||||
*/
|
||||
setBicubic: function (canvas)
|
||||
{
|
||||
canvas.style['image-rendering'] = 'auto';
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
/**
|
||||
* Sets the touch-action property on the canvas style. Can be used to disable default browser touch actions.
|
||||
*/
|
||||
* Sets the touch-action property on the canvas style. Can be used to disable default browser touch actions.
|
||||
*
|
||||
* @function Phaser.Display.Canvas.TouchAction
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {HTMLCanvasElement} canvas - The canvas element to have the style applied to.
|
||||
* @param {string} [value='none'] - The touch action value to set on the canvas. Set to `none` to disable touch actions.
|
||||
*
|
||||
* @return {HTMLCanvasElement} The canvas element.
|
||||
*/
|
||||
var TouchAction = function (canvas, value)
|
||||
{
|
||||
if (value === undefined) { value = 'none'; }
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
/**
|
||||
* Sets the user-select property on the canvas style. Can be used to disable default browser selection actions.
|
||||
*/
|
||||
* Sets the user-select property on the canvas style. Can be used to disable default browser selection actions.
|
||||
*
|
||||
* @function Phaser.Display.Canvas.UserSelect
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {HTMLCanvasElement} canvas - The canvas element to have the style applied to.
|
||||
* @param {string} [value='none'] - The touch callout value to set on the canvas. Set to `none` to disable touch callouts.
|
||||
*
|
||||
* @return {HTMLCanvasElement} The canvas element.
|
||||
*/
|
||||
var UserSelect = function (canvas, value)
|
||||
{
|
||||
if (value === undefined) { value = 'none'; }
|
||||
|
|
|
@ -6,6 +6,19 @@ var Color = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
/**
|
||||
* The Color class holds a single color value and allows for easy modification and reading of it.
|
||||
*
|
||||
* @class Color
|
||||
* @memberOf Phaser.Display
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {integer} [red=0] - The red color value. A number between 0 and 255.
|
||||
* @param {integer} [green=0] - The green color value. A number between 0 and 255.
|
||||
* @param {integer} [blue=0] - The blue color value. A number between 0 and 255.
|
||||
* @param {integer} [alpha=255] - The alpha value. A number between 0 and 255.
|
||||
*/
|
||||
function Color (red, green, blue, alpha)
|
||||
{
|
||||
if (red === undefined) { red = 0; }
|
||||
|
@ -13,21 +26,95 @@ var Color = new Class({
|
|||
if (blue === undefined) { blue = 0; }
|
||||
if (alpha === undefined) { alpha = 255; }
|
||||
|
||||
// All private
|
||||
/**
|
||||
* The internal red color value.
|
||||
*
|
||||
* @property {number} r
|
||||
* @private
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.r = 0;
|
||||
|
||||
/**
|
||||
* The internal green color value.
|
||||
*
|
||||
* @property {number} g
|
||||
* @private
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.g = 0;
|
||||
|
||||
/**
|
||||
* The internal blue color value.
|
||||
*
|
||||
* @property {number} b
|
||||
* @private
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.b = 0;
|
||||
|
||||
/**
|
||||
* The internal alpha color value.
|
||||
*
|
||||
* @property {number} a
|
||||
* @private
|
||||
* @default 255
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.a = 255;
|
||||
|
||||
this.gl = [ 0.0, 0.0, 0.0, 1.0 ];
|
||||
/**
|
||||
* An array containing the calculated color values for WebGL use.
|
||||
*
|
||||
* @property {array} gl
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.gl = [ 0, 0, 0, 1 ];
|
||||
|
||||
/**
|
||||
* Pre-calculated internal color value.
|
||||
*
|
||||
* @property {number} _color
|
||||
* @private
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._color = 0;
|
||||
|
||||
/**
|
||||
* Pre-calculated internal color32 value.
|
||||
*
|
||||
* @property {number} _color32
|
||||
* @private
|
||||
* @default 0
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._color32 = 0;
|
||||
|
||||
/**
|
||||
* Pre-calculated internal color rgb string value.
|
||||
*
|
||||
* @property {string} _rgba
|
||||
* @private
|
||||
* @default ''
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._rgba = '';
|
||||
|
||||
this.setTo(red, green, blue, alpha);
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets this color to be transparent. Sets all values to zero.
|
||||
*
|
||||
* @method Phaser.Curves.Color#transparent
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {Phaser.Display.Color} This Color object.
|
||||
*/
|
||||
transparent: function ()
|
||||
{
|
||||
this.red = 0;
|
||||
|
@ -38,7 +125,19 @@ var Color = new Class({
|
|||
return this.update();
|
||||
},
|
||||
|
||||
// Values are in the range 0 to 255
|
||||
/**
|
||||
* Sets the color of this Color component.
|
||||
*
|
||||
* @method Phaser.Curves.Color#setTo
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {integer} red - The red color value. A number between 0 and 255.
|
||||
* @param {integer} green - The green color value. A number between 0 and 255.
|
||||
* @param {integer} blue - The blue color value. A number between 0 and 255.
|
||||
* @param {integer} [alpha=255] - The alpha value. A number between 0 and 255.
|
||||
*
|
||||
* @return {Phaser.Display.Color} This Color object.
|
||||
*/
|
||||
setTo: function (red, green, blue, alpha)
|
||||
{
|
||||
if (alpha === undefined) { alpha = 255; }
|
||||
|
@ -51,7 +150,19 @@ var Color = new Class({
|
|||
return this.update();
|
||||
},
|
||||
|
||||
// Values are in the range 0 to 1
|
||||
/**
|
||||
* Sets the red, green, blue and alpha GL values of this Color component.
|
||||
*
|
||||
* @method Phaser.Curves.Color#setGLTo
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {float} red - The red color value. A number between 0 and 1.
|
||||
* @param {float} green - The green color value. A number between 0 and 1.
|
||||
* @param {float} blue - The blue color value. A number between 0 and 1.
|
||||
* @param {float} [alpha=1] - The alpha value. A number between 0 and 1.
|
||||
*
|
||||
* @return {Phaser.Display.Color} This Color object.
|
||||
*/
|
||||
setGLTo: function (red, green, blue, alpha)
|
||||
{
|
||||
if (alpha === undefined) { alpha = 1; }
|
||||
|
@ -64,6 +175,16 @@ var Color = new Class({
|
|||
return this.update();
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the color based on the color object given.
|
||||
*
|
||||
* @method Phaser.Curves.Color#setFromRGB
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {object} color - An object containing `r`, `g`, `b` and optionally `a` values in the range 0 to 255.
|
||||
*
|
||||
* @return {Phaser.Display.Color} This Color object.
|
||||
*/
|
||||
setFromRGB: function (color)
|
||||
{
|
||||
this.red = color.r;
|
||||
|
@ -78,6 +199,14 @@ var Color = new Class({
|
|||
return this.update();
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates the internal cache values.
|
||||
*
|
||||
* @method Phaser.Curves.Color#update
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {Phaser.Display.Color} This Color object.
|
||||
*/
|
||||
update: function ()
|
||||
{
|
||||
this._color = GetColor(this.r, this.g, this.b);
|
||||
|
@ -87,12 +216,27 @@ var Color = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
// Same as setRGB but performs safety checks on all the values given
|
||||
/**
|
||||
* Returns a new Color component using the values from this one.
|
||||
*
|
||||
* @method Phaser.Curves.Color#clone
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {Phaser.Display.Color} A new Color object.
|
||||
*/
|
||||
clone: function ()
|
||||
{
|
||||
return new Color(this.r, this.g, this.b, this.a);
|
||||
},
|
||||
|
||||
/**
|
||||
* The color of this Color component, not including the alpha channel.
|
||||
*
|
||||
* @name Phaser.Display.Color#color
|
||||
* @property {number} color
|
||||
* @readOnly
|
||||
* @since 3.0.0
|
||||
*/
|
||||
color: {
|
||||
|
||||
get: function ()
|
||||
|
@ -102,6 +246,14 @@ var Color = new Class({
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* The color of this Color component, including the alpha channel.
|
||||
*
|
||||
* @name Phaser.Display.Color#color32
|
||||
* @property {number} color32
|
||||
* @readOnly
|
||||
* @since 3.0.0
|
||||
*/
|
||||
color32: {
|
||||
|
||||
get: function ()
|
||||
|
@ -111,6 +263,14 @@ var Color = new Class({
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* The color of this Color component as a string which can be used in CSS color values.
|
||||
*
|
||||
* @name Phaser.Display.Color#rgba
|
||||
* @property {string} rgba
|
||||
* @readOnly
|
||||
* @since 3.0.0
|
||||
*/
|
||||
rgba: {
|
||||
|
||||
get: function ()
|
||||
|
@ -120,7 +280,13 @@ var Color = new Class({
|
|||
|
||||
},
|
||||
|
||||
// Gets and sets the red value, normalized to the 0 to 1 range
|
||||
/**
|
||||
* The red color value, normalized to the range 0 to 1.
|
||||
*
|
||||
* @name Phaser.Display.Color#redGL
|
||||
* @property {float} redGL
|
||||
* @since 3.0.0
|
||||
*/
|
||||
redGL: {
|
||||
|
||||
get: function ()
|
||||
|
@ -139,6 +305,13 @@ var Color = new Class({
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* The green color value, normalized to the range 0 to 1.
|
||||
*
|
||||
* @name Phaser.Display.Color#greenGL
|
||||
* @property {float} greenGL
|
||||
* @since 3.0.0
|
||||
*/
|
||||
greenGL: {
|
||||
|
||||
get: function ()
|
||||
|
@ -157,6 +330,13 @@ var Color = new Class({
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* The blue color value, normalized to the range 0 to 1.
|
||||
*
|
||||
* @name Phaser.Display.Color#blueGL
|
||||
* @property {float} blueGL
|
||||
* @since 3.0.0
|
||||
*/
|
||||
blueGL: {
|
||||
|
||||
get: function ()
|
||||
|
@ -175,6 +355,13 @@ var Color = new Class({
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* The alpha color value, normalized to the range 0 to 1.
|
||||
*
|
||||
* @name Phaser.Display.Color#alphaGL
|
||||
* @property {float} alphaGL
|
||||
* @since 3.0.0
|
||||
*/
|
||||
alphaGL: {
|
||||
|
||||
get: function ()
|
||||
|
@ -193,7 +380,13 @@ var Color = new Class({
|
|||
|
||||
},
|
||||
|
||||
// Gets and sets the red value, normalized to the 0 to 255 range
|
||||
/**
|
||||
* The red color value, normalized to the range 0 to 255.
|
||||
*
|
||||
* @name Phaser.Display.Color#red
|
||||
* @property {float} red
|
||||
* @since 3.0.0
|
||||
*/
|
||||
red: {
|
||||
|
||||
get: function ()
|
||||
|
@ -214,6 +407,13 @@ var Color = new Class({
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* The green color value, normalized to the range 0 to 255.
|
||||
*
|
||||
* @name Phaser.Display.Color#green
|
||||
* @property {float} green
|
||||
* @since 3.0.0
|
||||
*/
|
||||
green: {
|
||||
|
||||
get: function ()
|
||||
|
@ -234,6 +434,13 @@ var Color = new Class({
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* The blue color value, normalized to the range 0 to 255.
|
||||
*
|
||||
* @name Phaser.Display.Color#blue
|
||||
* @property {float} blue
|
||||
* @since 3.0.0
|
||||
*/
|
||||
blue: {
|
||||
|
||||
get: function ()
|
||||
|
@ -254,6 +461,13 @@ var Color = new Class({
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* The alpha color value, normalized to the range 0 to 255.
|
||||
*
|
||||
* @name Phaser.Display.Color#alpha
|
||||
* @property {float} alpha
|
||||
* @since 3.0.0
|
||||
*/
|
||||
alpha: {
|
||||
|
||||
get: function ()
|
||||
|
|
|
@ -1,3 +1,21 @@
|
|||
/**
|
||||
* @typedef {Object} ColorObject
|
||||
* @property {number} r - The red color value in the range 0 to 255.
|
||||
* @property {number} g - The green color value in the range 0 to 255.
|
||||
* @property {number} b - The blue color value in the range 0 to 255.
|
||||
* @property {number} a - The alpha color value in the range 0 to 255.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Converts the given color value into an Object containing r,g,b and a properties.
|
||||
*
|
||||
* @function Phaser.Display.Color.ColorToRGBA
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} color - A color value, optionally including the alpha value.
|
||||
*
|
||||
* @return {ColorObject} An object containing the parsed color values.
|
||||
*/
|
||||
var ColorToRGBA = function (color)
|
||||
{
|
||||
var output = {
|
||||
|
|
|
@ -1,6 +1,13 @@
|
|||
// Return a string containing a hex representation of the given color component.
|
||||
// @param {integer} color - The color channel to get the hex value for, must be a value between 0 and 255.
|
||||
// @return {string} A string of length 2 characters, i.e. 255 = ff, 100 = 64.
|
||||
/**
|
||||
* Returns a string containing a hex representation of the given color component.
|
||||
*
|
||||
* @function Phaser.Display.Color.ComponentToHex
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {integer} color - The color channel to get the hex value for, must be a value between 0 and 255.
|
||||
*
|
||||
* @return {string} A string of length 2 characters, i.e. 255 = ff, 100 = 64.
|
||||
*/
|
||||
var ComponentToHex = function (color)
|
||||
{
|
||||
var hex = color.toString(16);
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
/**
|
||||
* Given 3 color values this will return an integer representation of it.
|
||||
* Given 3 separate color values this will return an integer representation of it.
|
||||
*
|
||||
* @function Phaser.Display.Color.GetColor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {integer} red - The red color value. A number between 0 and 255.
|
||||
* @param {integer} green - The green color value. A number between 0 and 255.
|
||||
* @param {integer} blue - The blue color value. A number between 0 and 255.
|
||||
*
|
||||
* @return {number} The combined color value.
|
||||
*/
|
||||
var GetColor = function (red, green, blue)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,15 @@
|
|||
/**
|
||||
* Given an alpha and 3 color values this will return an integer representation of it.
|
||||
*
|
||||
* @function Phaser.Display.Color.GetColor32
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {integer} red - The red color value. A number between 0 and 255.
|
||||
* @param {integer} green - The green color value. A number between 0 and 255.
|
||||
* @param {integer} blue - The blue color value. A number between 0 and 255.
|
||||
* @param {integer} alpha - The alpha color value. A number between 0 and 255.
|
||||
*
|
||||
* @return {number} The combined color value.
|
||||
*/
|
||||
var GetColor32 = function (red, green, blue, alpha)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,18 @@
|
|||
var Color = require('./Color');
|
||||
var HueToComponent = require('./HueToComponent');
|
||||
|
||||
/**
|
||||
* Converts HSL (hue, saturation and lightness) values to a Phaser Color object.
|
||||
*
|
||||
* @function Phaser.Display.Color.HSLToColor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} h - The hue value in the range 0 to 1.
|
||||
* @param {number} s - The saturation value in the range 0 to 1.
|
||||
* @param {number} l - The lightness value in the range 0 to 1.
|
||||
*
|
||||
* @return {Phaser.Display.Color} A Color object created from the results of the h, s and l values.
|
||||
*/
|
||||
var HSLToColor = function (h, s, l)
|
||||
{
|
||||
// achromatic by default
|
||||
|
|
|
@ -1,8 +1,16 @@
|
|||
var HSVToRGB = require('./HSVToRGB');
|
||||
|
||||
/**
|
||||
* Get HSV color wheel values in an array which will be 360 elements in size.
|
||||
*/
|
||||
* Get HSV color wheel values in an array which will be 360 elements in size.
|
||||
*
|
||||
* @function Phaser.Display.Color.HSVColorWheel
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} [s=1] - The saturation, in the range 0 - 1.
|
||||
* @param {number} [v=1] - The value, in the range 0 - 1.
|
||||
*
|
||||
* @return {array} An array containing 360 elements, where each contains a single numeric value corresponding to the color at that point in the HSV color wheel.
|
||||
*/
|
||||
var HSVColorWheel = function (s, v)
|
||||
{
|
||||
if (s === undefined) { s = 1; }
|
||||
|
|
|
@ -3,8 +3,17 @@ var GetColor = require('./GetColor');
|
|||
/**
|
||||
* Converts an HSV (hue, saturation and value) color value to RGB.
|
||||
* Conversion formula from http://en.wikipedia.org/wiki/HSL_color_space.
|
||||
* Assumes HSV values are contained in the set [0, 1] and returns r, g and b values in the set [0, 255].
|
||||
* Assumes HSV values are contained in the set [0, 1].
|
||||
* Based on code by Michael Jackson (https://github.com/mjijackson)
|
||||
*
|
||||
* @function Phaser.Display.Color.HSVToRGB
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} h - The hue, in the range 0 - 1.
|
||||
* @param {number} s - The saturation, in the range 0 - 1.
|
||||
* @param {number} v - The value, in the range 0 - 1.
|
||||
*
|
||||
* @return {ColorObject} An object with the red, green and blue values set in the r, g and b properties.
|
||||
*/
|
||||
var HSVToRGB = function (h, s, v)
|
||||
{
|
||||
|
|
|
@ -1,22 +1,30 @@
|
|||
var Color = require('./Color');
|
||||
|
||||
/**
|
||||
* Converts a hex string into a Phaser Color object.
|
||||
*
|
||||
* The hex string can supplied as `'#0033ff'` or the short-hand format of `'#03f'`; it can begin with an optional "#" or "0x", or be unprefixed.
|
||||
*
|
||||
* An alpha channel is _not_ supported.
|
||||
*/
|
||||
* Converts a hex string into a Phaser Color object.
|
||||
*
|
||||
* The hex string can supplied as `'#0033ff'` or the short-hand format of `'#03f'`; it can begin with an optional "#" or "0x", or be unprefixed.
|
||||
*
|
||||
* An alpha channel is _not_ supported.
|
||||
*
|
||||
* @function Phaser.Display.Color.HexStringToColor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} hex - The hex color value to convert, such as `#0033ff` or the short-hand format: `#03f`.
|
||||
*
|
||||
* @return {Phaser.Display.Color} A Color object populated by the values of the given string.
|
||||
*/
|
||||
var HexStringToColor = function (hex)
|
||||
{
|
||||
var color = new Color();
|
||||
|
||||
// Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
|
||||
hex = hex.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i, function(m, r, g, b) {
|
||||
hex = hex.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i, function (m, r, g, b)
|
||||
{
|
||||
return r + r + g + g + b + b;
|
||||
});
|
||||
|
||||
var result = /^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
||||
var result = (/^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i).exec(hex);
|
||||
|
||||
if (result)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,16 @@
|
|||
/**
|
||||
* Converts a hue to an RGB color.
|
||||
* Based on code by Michael Jackson (https://github.com/mjijackson)
|
||||
*/
|
||||
* Converts a hue to an RGB color.
|
||||
* Based on code by Michael Jackson (https://github.com/mjijackson)
|
||||
*
|
||||
* @function Phaser.Display.Color.HueToComponent
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} p
|
||||
* @param {number} q
|
||||
* @param {number} t
|
||||
*
|
||||
* @return {number} The combined color value.
|
||||
*/
|
||||
var HueToComponent = function (p, q, t)
|
||||
{
|
||||
if (t < 0)
|
||||
|
|
|
@ -1,6 +1,16 @@
|
|||
var Color = require('./Color');
|
||||
var IntegerToRGB = require('./IntegerToRGB');
|
||||
|
||||
/**
|
||||
* Converts the given color value into an instance of a Color object.
|
||||
*
|
||||
* @function Phaser.Display.Color.IntegerToColor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {integer} input - The color value to convert into a Color object.
|
||||
*
|
||||
* @return {Phaser.Display.Color} A Color object.
|
||||
*/
|
||||
var IntegerToColor = function (input)
|
||||
{
|
||||
var rgb = IntegerToRGB(input);
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
/**
|
||||
* Return the component parts of a color as an Object with the properties alpha, red, green, blue.
|
||||
*
|
||||
* Alpha will only be set if it exists in the given color (0xAARRGGBB)
|
||||
*/
|
||||
* Return the component parts of a color as an Object with the properties alpha, red, green, blue.
|
||||
*
|
||||
* Alpha will only be set if it exists in the given color (0xAARRGGBB)
|
||||
*
|
||||
* @function Phaser.Display.Color.IntegerToRGB
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {integer} input - The color value to convert into a Color object.
|
||||
*
|
||||
* @return {ColorObject} An object with the red, green and blue values set in the r, g and b properties.
|
||||
*/
|
||||
var IntegerToRGB = function (color)
|
||||
{
|
||||
if (color > 16777215)
|
||||
|
|
|
@ -1,5 +1,15 @@
|
|||
var Color = require('./Color');
|
||||
|
||||
/**
|
||||
* Converts an object containing `r`, `g`, `b` and `a` properties into a Color class instance.
|
||||
*
|
||||
* @function Phaser.Display.Color.ObjectToColor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {object} input - An object containing `r`, `g`, `b` and `a` properties in the range 0 to 255.
|
||||
*
|
||||
* @return {Phaser.Display.Color} A Color object.
|
||||
*/
|
||||
var ObjectToColor = function (input)
|
||||
{
|
||||
return new Color(input.r, input.g, input.b, input.a);
|
||||
|
|
|
@ -1,15 +1,22 @@
|
|||
var Color = require('./Color');
|
||||
|
||||
/**
|
||||
* Converts a CSS 'web' string into a Phaser Color object.
|
||||
*
|
||||
* The web string can be in the format `'rgb(r,g,b)'` or `'rgba(r,g,b,a)'` where r/g/b are in the range [0..255] and a is in the range [0..1].
|
||||
*/
|
||||
* Converts a CSS 'web' string into a Phaser Color object.
|
||||
*
|
||||
* The web string can be in the format `'rgb(r,g,b)'` or `'rgba(r,g,b,a)'` where r/g/b are in the range [0..255] and a is in the range [0..1].
|
||||
*
|
||||
* @function Phaser.Display.Color.RGBStringToColor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {string} rgb - The CSS format color string, using the `rgb` or `rgba` format.
|
||||
*
|
||||
* @return {Phaser.Display.Color} A Color object.
|
||||
*/
|
||||
var RGBStringToColor = function (rgb)
|
||||
{
|
||||
var color = new Color();
|
||||
|
||||
var result = /^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(rgb.toLowerCase());
|
||||
var result = (/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/).exec(rgb.toLowerCase());
|
||||
|
||||
if (result)
|
||||
{
|
||||
|
|
|
@ -1,9 +1,18 @@
|
|||
/**
|
||||
* Converts an RGB color value to HSV (hue, saturation and value).
|
||||
* Conversion forumla from http://en.wikipedia.org/wiki/HSL_color_space.
|
||||
* Assumes RGB values are contained in the set [0, 255] and returns h, s and v in the set [0, 1].
|
||||
* Based on code by Michael Jackson (https://github.com/mjijackson)
|
||||
*/
|
||||
* Converts an RGB color value to HSV (hue, saturation and value).
|
||||
* Conversion forumla from http://en.wikipedia.org/wiki/HSL_color_space.
|
||||
* Assumes RGB values are contained in the set [0, 255] and returns h, s and v in the set [0, 1].
|
||||
* Based on code by Michael Jackson (https://github.com/mjijackson)
|
||||
*
|
||||
* @function Phaser.Display.Color.RGBToHSV
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {integer} r - The red color value. A number between 0 and 255.
|
||||
* @param {integer} g - The green color value. A number between 0 and 255.
|
||||
* @param {integer} b - The blue color value. A number between 0 and 255.
|
||||
*
|
||||
* @return {object} An object with the properties `h`, `s` and `v`.
|
||||
*/
|
||||
var RGBToHSV = function (r, g, b)
|
||||
{
|
||||
r /= 255;
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
var ComponentToHex = require('./ComponentToHex');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Converts the color values into an HTML compatible color string, prefixed with either `#` or `0x`.
|
||||
*
|
||||
* @function Phaser.Display.Color.RGBToString
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {integer} r - [description]
|
||||
* @param {integer} g - [description]
|
||||
* @param {integer} b - [description]
|
||||
* @param {integer} [a=255] - [description]
|
||||
* @param {string} [prefix=#] - [description]
|
||||
* @param {integer} r - The red color value. A number between 0 and 255.
|
||||
* @param {integer} g - The green color value. A number between 0 and 255.
|
||||
* @param {integer} b - The blue color value. A number between 0 and 255.
|
||||
* @param {integer} [a=255] - The alpha value. A number between 0 and 255.
|
||||
* @param {string} [prefix=#] - The prefix of the string. Either `#` or `0x`.
|
||||
*
|
||||
* @return {string} [description]
|
||||
* @return {string} A string-based representation of the color values.
|
||||
*/
|
||||
var RGBToString = function (r, g, b, a, prefix)
|
||||
{
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue