Merge pull request #5 from photonstorm/master

keeping up with master again.
This commit is contained in:
svipal 2020-02-05 18:45:52 +01:00 committed by GitHub
commit 786834be5e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
81 changed files with 572 additions and 367 deletions

View file

@ -2,6 +2,30 @@
## Version 3.23 - Ginro - in development ## Version 3.23 - Ginro - in development
### JSDocs
The following sections now have 100% complete JSDoc coverage:
* Animations
* Create
* Geom
* Math
* Renderer
* Textures
### Removed
The following features have been removed in this version of Phaser:
* Impact Physics has been removed completely and is no longer a choice of physics system. The resulting `Scene.impact` property and Impact config object have also been removed.
### Deprecated
The following features are now deprecated and will be removed in a future version of Phaser:
* The Light Pipeline and associated components will be removed. This feature was never properly finished and adds too much redundant, non-optional code into the core API. The ability to load normal maps alongside textures will _remain_, for use in your own lighting shaders, which gives you far more control over the final effect.
### New Features ### New Features
* `Line.GetEasedPoints` is a new function that will take a Line, a quantity, and an ease function, and returns an array of points where each point has been spaced out across the length of the Line based on the ease function given. * `Line.GetEasedPoints` is a new function that will take a Line, a quantity, and an ease function, and returns an array of points where each point has been spaced out across the length of the Line based on the ease function given.
@ -15,16 +39,22 @@
* `XHRLoader` will now use the `XHRSettings.withCredentials` as set in the file or global loader config. * `XHRLoader` will now use the `XHRSettings.withCredentials` as set in the file or global loader config.
* `Animation.setCurrentFrame` will no longer try to call `setOrigin` or `updateDisplayOrigin` if the Game Object doesn't have the Origin component, preventing unknown function errors. * `Animation.setCurrentFrame` will no longer try to call `setOrigin` or `updateDisplayOrigin` if the Game Object doesn't have the Origin component, preventing unknown function errors.
* `MatterTileBody` now extends `EventEmitter`, meaning you can listen to collision events from Tiles directly and it will no longer throw errors about `gameObject.emit` not working. Fix #4967 (thanks @reinildo) * `MatterTileBody` now extends `EventEmitter`, meaning you can listen to collision events from Tiles directly and it will no longer throw errors about `gameObject.emit` not working. Fix #4967 (thanks @reinildo)
* Added `MatterJS.BodyType` to `GameObject.body` type. Fix #4962 (thanks @meisterpeeps)
### Bug Fixes ### Bug Fixes
* The conditional checking if the `PathFollower` was at the end of the path or not was incorrect (thanks @samme) * The conditional checking if the `PathFollower` was at the end of the path or not was incorrect (thanks @samme)
* Creating an `Arcade Physics Body` from a scaled Game Object would use the un-scaled dimensions for the body. They now use the scaled dimensions. This may be a breaking change in some games, so please be aware of it (thanks @samme)
* Creating an `Arcade Physics Static Body` from a scaled Game Object would use the un-scaled dimensions for the body. They now use the scaled dimensions. This may be a breaking change in some games, so please be aware of it (thanks @samme)
* The `Arcade Physics Static Body` center was incorrect after construction. Probably caused problems with circle collisions. Fix #4770 (thanks @samme)
* An Arcade Physics Body `center` and `position` are now correct after construction and before preUpdate(), for any Game Object origin or scale (thanks @samme)
* When calling `Body.setSize` with the `center` parameter as `true` the calculated offset would be incorrect for scaled Game Objects. The offset now takes scaling into consideration (thanks @samme)
### Examples, Documentation and TypeScript ### Examples, Documentation and TypeScript
My thanks to the following for helping with the Phaser 3 Examples, Docs and TypeScript definitions, either by reporting errors, fixing them or helping author the docs: My thanks to the following for helping with the Phaser 3 Examples, Docs and TypeScript definitions, either by reporting errors, fixing them or helping author the docs:
@JasonHK @JasonHK @supertommy
## Version 3.22 - Kohaku - January 15th 2020 ## Version 3.22 - Kohaku - January 15th 2020

View file

@ -224,7 +224,7 @@ var Animation = new Class({
* @method Phaser.Animations.Animation#addFrame * @method Phaser.Animations.Animation#addFrame
* @since 3.0.0 * @since 3.0.0
* *
* @param {(string|Phaser.Types.Animations.AnimationFrame[])} config - [description] * @param {(string|Phaser.Types.Animations.AnimationFrame[])} config - Either a string, in which case it will use all frames from a texture with the matching key, or an array of Animation Frame configuration objects.
* *
* @return {Phaser.Animations.Animation} This Animation object. * @return {Phaser.Animations.Animation} This Animation object.
*/ */
@ -240,7 +240,7 @@ var Animation = new Class({
* @since 3.0.0 * @since 3.0.0
* *
* @param {integer} index - The index to insert the frame at within the animation. * @param {integer} index - The index to insert the frame at within the animation.
* @param {(string|Phaser.Types.Animations.AnimationFrame[])} config - [description] * @param {(string|Phaser.Types.Animations.AnimationFrame[])} config - Either a string, in which case it will use all frames from a texture with the matching key, or an array of Animation Frame configuration objects.
* *
* @return {Phaser.Animations.Animation} This Animation object. * @return {Phaser.Animations.Animation} This Animation object.
*/ */
@ -288,13 +288,14 @@ var Animation = new Class({
}, },
/** /**
* [description] * Called internally when this Animation completes playback.
* Optionally, hides the parent Game Object, then stops playback.
* *
* @method Phaser.Animations.Animation#completeAnimation * @method Phaser.Animations.Animation#completeAnimation
* @protected * @protected
* @since 3.0.0 * @since 3.0.0
* *
* @param {Phaser.GameObjects.Components.Animation} component - [description] * @param {Phaser.GameObjects.Components.Animation} component - The Animation Component belonging to the Game Object invoking this call.
*/ */
completeAnimation: function (component) completeAnimation: function (component)
{ {
@ -307,14 +308,15 @@ var Animation = new Class({
}, },
/** /**
* [description] * Called internally when this Animation first starts to play.
* Sets the accumulator and nextTick properties.
* *
* @method Phaser.Animations.Animation#getFirstTick * @method Phaser.Animations.Animation#getFirstTick
* @protected * @protected
* @since 3.0.0 * @since 3.0.0
* *
* @param {Phaser.GameObjects.Components.Animation} component - [description] * @param {Phaser.GameObjects.Components.Animation} component - The Animation Component belonging to the Game Object invoking this call.
* @param {boolean} [includeDelay=true] - [description] * @param {boolean} [includeDelay=true] - If `true` the Animation Components delay value will be added to the `nextTick` total.
*/ */
getFirstTick: function (component, includeDelay) getFirstTick: function (component, includeDelay)
{ {
@ -347,16 +349,16 @@ var Animation = new Class({
}, },
/** /**
* [description] * Creates AnimationFrame instances based on the given frame data.
* *
* @method Phaser.Animations.Animation#getFrames * @method Phaser.Animations.Animation#getFrames
* @since 3.0.0 * @since 3.0.0
* *
* @param {Phaser.Textures.TextureManager} textureManager - [description] * @param {Phaser.Textures.TextureManager} textureManager - A reference to the global Texture Manager.
* @param {(string|Phaser.Types.Animations.AnimationFrame[])} frames - [description] * @param {(string|Phaser.Types.Animations.AnimationFrame[])} frames - Either a string, in which case it will use all frames from a texture with the matching key, or an array of Animation Frame configuration objects.
* @param {string} [defaultTextureKey] - [description] * @param {string} [defaultTextureKey] - The key to use if no key is set in the frame configuration object.
* *
* @return {Phaser.Animations.AnimationFrame[]} [description] * @return {Phaser.Animations.AnimationFrame[]} An array of newly created AnimationFrame instances.
*/ */
getFrames: function (textureManager, frames, defaultTextureKey) getFrames: function (textureManager, frames, defaultTextureKey)
{ {
@ -449,12 +451,12 @@ var Animation = new Class({
}, },
/** /**
* [description] * Called internally. Sets the accumulator and nextTick values of the current Animation.
* *
* @method Phaser.Animations.Animation#getNextTick * @method Phaser.Animations.Animation#getNextTick
* @since 3.0.0 * @since 3.0.0
* *
* @param {Phaser.GameObjects.Components.Animation} component - [description] * @param {Phaser.GameObjects.Components.Animation} component - The Animation Component belonging to the Game Object invoking this call.
*/ */
getNextTick: function (component) getNextTick: function (component)
{ {
@ -624,12 +626,13 @@ var Animation = new Class({
}, },
/** /**
* [description] * Called internally when the Animation is playing backwards.
* Sets the previous frame, causing a yoyo, repeat, complete or update, accordingly.
* *
* @method Phaser.Animations.Animation#previousFrame * @method Phaser.Animations.Animation#previousFrame
* @since 3.0.0 * @since 3.0.0
* *
* @param {Phaser.GameObjects.Components.Animation} component - [description] * @param {Phaser.GameObjects.Components.Animation} component - The Animation Component belonging to the Game Object invoking this call.
*/ */
previousFrame: function (component) previousFrame: function (component)
{ {
@ -687,12 +690,13 @@ var Animation = new Class({
}, },
/** /**
* [description] * Removes the given AnimationFrame from this Animation instance.
* This is a global action. Any Game Object using this Animation will be impacted by this change.
* *
* @method Phaser.Animations.Animation#removeFrame * @method Phaser.Animations.Animation#removeFrame
* @since 3.0.0 * @since 3.0.0
* *
* @param {Phaser.Animations.AnimationFrame} frame - [description] * @param {Phaser.Animations.AnimationFrame} frame - The AnimationFrame to be removed.
* *
* @return {Phaser.Animations.Animation} This Animation object. * @return {Phaser.Animations.Animation} This Animation object.
*/ */
@ -729,7 +733,8 @@ var Animation = new Class({
}, },
/** /**
* [description] * Called internally during playback. Forces the animation to repeat, providing there are enough counts left
* in the repeat counter.
* *
* @method Phaser.Animations.Animation#repeatAnimation * @method Phaser.Animations.Animation#repeatAnimation
* @fires Phaser.Animations.Events#ANIMATION_REPEAT * @fires Phaser.Animations.Events#ANIMATION_REPEAT
@ -737,7 +742,7 @@ var Animation = new Class({
* @fires Phaser.Animations.Events#SPRITE_ANIMATION_KEY_REPEAT * @fires Phaser.Animations.Events#SPRITE_ANIMATION_KEY_REPEAT
* @since 3.0.0 * @since 3.0.0
* *
* @param {Phaser.GameObjects.Components.Animation} component - [description] * @param {Phaser.GameObjects.Components.Animation} component - The Animation Component belonging to the Game Object invoking this call.
*/ */
repeatAnimation: function (component) repeatAnimation: function (component)
{ {
@ -782,7 +787,7 @@ var Animation = new Class({
* @method Phaser.Animations.Animation#setFrame * @method Phaser.Animations.Animation#setFrame
* @since 3.0.0 * @since 3.0.0
* *
* @param {Phaser.GameObjects.Components.Animation} component - [description] * @param {Phaser.GameObjects.Components.Animation} component - The Animation Component belonging to the Game Object invoking this call.
*/ */
setFrame: function (component) setFrame: function (component)
{ {
@ -803,7 +808,7 @@ var Animation = new Class({
* @method Phaser.Animations.Animation#toJSON * @method Phaser.Animations.Animation#toJSON
* @since 3.0.0 * @since 3.0.0
* *
* @return {Phaser.Types.Animations.JSONAnimation} [description] * @return {Phaser.Types.Animations.JSONAnimation} The resulting JSONAnimation formatted object.
*/ */
toJSON: function () toJSON: function ()
{ {
@ -831,7 +836,7 @@ var Animation = new Class({
}, },
/** /**
* [description] * Called internally whenever frames are added to, or removed from, this Animation.
* *
* @method Phaser.Animations.Animation#updateFrameSequence * @method Phaser.Animations.Animation#updateFrameSequence
* @since 3.0.0 * @since 3.0.0
@ -888,7 +893,7 @@ var Animation = new Class({
}, },
/** /**
* [description] * Pauses playback of this Animation. The paused state is set immediately.
* *
* @method Phaser.Animations.Animation#pause * @method Phaser.Animations.Animation#pause
* @since 3.0.0 * @since 3.0.0
@ -903,7 +908,7 @@ var Animation = new Class({
}, },
/** /**
* [description] * Resumes playback of this Animation. The paused state is reset immediately.
* *
* @method Phaser.Animations.Animation#resume * @method Phaser.Animations.Animation#resume
* @since 3.0.0 * @since 3.0.0
@ -918,7 +923,9 @@ var Animation = new Class({
}, },
/** /**
* [description] * Destroys this Animation instance. It will remove all event listeners,
* remove this animation and its key from the global Animation Manager,
* and then destroy all Animation Frames in turn.
* *
* @method Phaser.Animations.Animation#destroy * @method Phaser.Animations.Animation#destroy
* @since 3.0.0 * @since 3.0.0

View file

@ -262,7 +262,34 @@ var AnimationManager = new Class({
}, },
/** /**
* [description] * Generate an array of {@link Phaser.Types.Animations.AnimationFrame} objects from a texture key and configuration object.
*
* Generates objects with string based frame names, as configured by the given {@link Phaser.Types.Animations.GenerateFrameNames}.
*
* It's a helper method, designed to make it easier for you to extract all of the frame names from texture atlases.
* If you're working with a sprite sheet, see the `generateFrameNumbers` method instead.
*
* Example:
*
* If you have a texture atlases loaded called `gems` and it contains 6 frames called `ruby_0001`, `ruby_0002`, and so on,
* then you can call this method using: `this.anims.generateFrameNames('gems', { prefix: 'ruby_', end: 6, zeroPad: 4 })`.
*
* The `end` value tells it to look for 6 frames, incrementally numbered, all starting with the prefix `ruby_`. The `zeroPad`
* value tells it how many zeroes pad out the numbers. To create an animation using this method, you can do:
*
* ```javascript
* this.anims.create({
* key: 'ruby',
* repeat: -1,
* frames: this.anims.generateFrameNames('gems', {
* prefix: 'ruby_',
* end: 6,
* zeroPad: 4
* })
* });
* ```
*
* Please see the animation examples for further details.
* *
* @method Phaser.Animations.AnimationManager#generateFrameNames * @method Phaser.Animations.AnimationManager#generateFrameNames
* @since 3.0.0 * @since 3.0.0
@ -341,6 +368,8 @@ var AnimationManager = new Class({
* *
* Generates objects with numbered frame names, as configured by the given {@link Phaser.Types.Animations.GenerateFrameNumbers}. * Generates objects with numbered frame names, as configured by the given {@link Phaser.Types.Animations.GenerateFrameNumbers}.
* *
* If you're working with a texture atlas, see the `generateFrameNames` method instead.
*
* @method Phaser.Animations.AnimationManager#generateFrameNumbers * @method Phaser.Animations.AnimationManager#generateFrameNumbers
* @since 3.0.0 * @since 3.0.0
* *
@ -505,7 +534,10 @@ var AnimationManager = new Class({
}, },
/** /**
* Remove an animation. * Removes an Animation from this Animation Manager, based on the given key.
*
* This is a global action. Once an Animation has been removed, no Game Objects
* can carry on using it.
* *
* @method Phaser.Animations.AnimationManager#remove * @method Phaser.Animations.AnimationManager#remove
* @fires Phaser.Animations.Events#REMOVE_ANIMATION * @fires Phaser.Animations.Events#REMOVE_ANIMATION
@ -513,7 +545,7 @@ var AnimationManager = new Class({
* *
* @param {string} key - The key of the animation to remove. * @param {string} key - The key of the animation to remove.
* *
* @return {Phaser.Animations.Animation} [description] * @return {Phaser.Animations.Animation} The Animation instance that was removed from the Animation Manager.
*/ */
remove: function (key) remove: function (key)
{ {
@ -591,35 +623,36 @@ var AnimationManager = new Class({
}, },
/** /**
* Get the animation data as javascript object by giving key, or get the data of all animations as array of objects, if key wasn't provided. * Returns the Animation data as JavaScript object based on the given key.
* Or, if not key is defined, it will return the data of all animations as array of objects.
* *
* @method Phaser.Animations.AnimationManager#toJSON * @method Phaser.Animations.AnimationManager#toJSON
* @since 3.0.0 * @since 3.0.0
* *
* @param {string} key - [description] * @param {string} [key] - The animation to get the JSONAnimation data from. If not provided, all animations are returned as an array.
* *
* @return {Phaser.Types.Animations.JSONAnimations} [description] * @return {Phaser.Types.Animations.JSONAnimations} The resulting JSONAnimations formatted object.
*/ */
toJSON: function (key) toJSON: function (key)
{
if (key !== undefined && key !== '')
{
return this.anims.get(key).toJSON();
}
else
{ {
var output = { var output = {
anims: [], anims: [],
globalTimeScale: this.globalTimeScale globalTimeScale: this.globalTimeScale
}; };
if (key !== undefined && key !== '')
{
output.anims.push(this.anims.get(key).toJSON());
}
else
{
this.anims.each(function (animationKey, animation) this.anims.each(function (animationKey, animation)
{ {
output.anims.push(animation.toJSON()); output.anims.push(animation.toJSON());
}); });
}
return output; return output;
}
}, },
/** /**

View file

@ -3,7 +3,7 @@
* @since 3.0.0 * @since 3.0.0
* *
* @property {string} key - The key that the animation will be associated with. i.e. sprite.animations.play(key) * @property {string} key - The key that the animation will be associated with. i.e. sprite.animations.play(key)
* @property {(string|number)} frame - [description] * @property {(string|number)} frame - The key, or index number, of the frame within the animation.
* @property {number} [duration=0] - [description] * @property {number} [duration=0] - The duration, in ms, of this frame of the animation.
* @property {boolean} [visible] - [description] * @property {boolean} [visible] - Should the parent Game Object be visible during this frame of the animation?
*/ */

View file

@ -4,7 +4,7 @@
* *
* @property {string} key - The key that the animation will be associated with. i.e. sprite.animations.play(key) * @property {string} key - The key that the animation will be associated with. i.e. sprite.animations.play(key)
* @property {string} type - A frame based animation (as opposed to a bone based animation) * @property {string} type - A frame based animation (as opposed to a bone based animation)
* @property {Phaser.Types.Animations.JSONAnimationFrame[]} frames - [description] * @property {Phaser.Types.Animations.JSONAnimationFrame[]} frames - An array of the AnimationFrame objects inside this Animation.
* @property {integer} frameRate - The frame rate of playback in frames per second (default 24 if duration is null) * @property {integer} frameRate - The frame rate of playback in frames per second (default 24 if duration is null)
* @property {integer} duration - How long the animation should play for in milliseconds. If not given its derived from frameRate. * @property {integer} duration - How long the animation should play for in milliseconds. If not given its derived from frameRate.
* @property {boolean} skipMissedFrames - Skip frames if the time lags, or always advanced anyway? * @property {boolean} skipMissedFrames - Skip frames if the time lags, or always advanced anyway?

View file

@ -4,6 +4,5 @@
* *
* @property {string} [default] - The default physics system. It will be started for each scene. Phaser provides 'arcade', 'impact', and 'matter'. * @property {string} [default] - The default physics system. It will be started for each scene. Phaser provides 'arcade', 'impact', and 'matter'.
* @property {Phaser.Types.Physics.Arcade.ArcadeWorldConfig} [arcade] - Arcade Physics configuration. * @property {Phaser.Types.Physics.Arcade.ArcadeWorldConfig} [arcade] - Arcade Physics configuration.
* @property {Phaser.Types.Physics.Impact.WorldConfig} [impact] - Impact Physics configuration.
* @property {Phaser.Types.Physics.Matter.MatterWorldConfig} [matter] - Matter Physics configuration. * @property {Phaser.Types.Physics.Matter.MatterWorldConfig} [matter] - Matter Physics configuration.
*/ */

View file

@ -9,14 +9,42 @@ var CanvasPool = require('../display/canvas/CanvasPool');
var GetValue = require('../utils/object/GetValue'); var GetValue = require('../utils/object/GetValue');
/** /**
* [description] * Generates a texture based on the given Create configuration object.
*
* The texture is drawn using a fixed-size indexed palette of 16 colors, where the hex value in the
* data cells map to a single color. For example, if the texture config looked like this:
*
* ```javascript
* var star = [
* '.....828.....',
* '....72227....',
* '....82228....',
* '...7222227...',
* '2222222222222',
* '8222222222228',
* '.72222222227.',
* '..787777787..',
* '..877777778..',
* '.78778887787.',
* '.27887.78872.',
* '.787.....787.'
* ];
*
* this.textures.generate('star', { data: star, pixelWidth: 4 });
* ```
*
* Then it would generate a texture that is 52 x 48 pixels in size, because each cell of the data array
* represents 1 pixel multiplied by the `pixelWidth` value. The cell values, such as `8`, maps to color
* number 8 in the palette. If a cell contains a period character `.` then it is transparent.
*
* The default palette is Arne16, but you can specify your own using the `palette` property.
* *
* @function Phaser.Create.GenerateTexture * @function Phaser.Create.GenerateTexture
* @since 3.0.0 * @since 3.0.0
* *
* @param {Phaser.Types.Create.GenerateTextureConfig} config - [description] * @param {Phaser.Types.Create.GenerateTextureConfig} config - The Generate Texture Configuration object.
* *
* @return {HTMLCanvasElement} [description] * @return {HTMLCanvasElement} An HTMLCanvasElement which contains the generated texture drawn to it.
*/ */
var GenerateTexture = function (config) var GenerateTexture = function (config)
{ {

View file

@ -2,21 +2,21 @@
* @callback Phaser.Types.Create.GenerateTextureCallback * @callback Phaser.Types.Create.GenerateTextureCallback
* @since 3.0.0 * @since 3.0.0
* *
* @param {HTMLCanvasElement} canvas - [description] * @param {HTMLCanvasElement} canvas - The HTML Canvas element to operate on.
* @param {CanvasRenderingContext2D} context - [description] * @param {CanvasRenderingContext2D} context - The context of the HTML Canvas element.
*/ */
/** /**
* @typedef {object} Phaser.Types.Create.GenerateTextureConfig * @typedef {object} Phaser.Types.Create.GenerateTextureConfig
* @since 3.0.0 * @since 3.0.0
* *
* @property {array} [data=[]] - [description] * @property {array} [data=[]] - An array of data, where each row is a string of single values 0-9A-F, or the period character.
* @property {HTMLCanvasElement} [canvas=null] - [description] * @property {HTMLCanvasElement} [canvas=null] - The HTML Canvas to draw the texture to.
* @property {Phaser.Types.Create.Palette} [palette=Arne16] - [description] * @property {Phaser.Types.Create.Palette} [palette=Arne16] - The indexed palette that the data cell values map to.
* @property {number} [pixelWidth=1] - The width of each 'pixel' in the generated texture. * @property {number} [pixelWidth=1] - The width of each 'pixel' in the generated texture.
* @property {number} [pixelHeight=1] - The height of each 'pixel' in the generated texture. * @property {number} [pixelHeight=1] - The height of each 'pixel' in the generated texture.
* @property {boolean} [resizeCanvas=true] - [description] * @property {boolean} [resizeCanvas=true] - Should the canvas be resized before the texture is drawn?
* @property {boolean} [clearCanvas=true] - [description] * @property {boolean} [clearCanvas=true] - Should the canvas be cleared before the texture is drawn?
* @property {Phaser.Types.Create.GenerateTextureCallback} [preRender] - [description] * @property {Phaser.Types.Create.GenerateTextureCallback} [preRender] - A callback to send the canvas to prior to the texture being drawn.
* @property {Phaser.Types.Create.GenerateTextureCallback} [postRender] - [description] * @property {Phaser.Types.Create.GenerateTextureCallback} [postRender] - A callback to send the canvas to after the texture has been drawn.
*/ */

View file

@ -166,10 +166,10 @@ var GameObject = new Class({
this.input = null; this.input = null;
/** /**
* If this Game Object is enabled for physics then this property will contain a reference to a Physics Body. * If this Game Object is enabled for Arcade or Matter Physics then this property will contain a reference to a Physics Body.
* *
* @name Phaser.GameObjects.GameObject#body * @name Phaser.GameObjects.GameObject#body
* @type {?(object|Phaser.Physics.Arcade.Body|Phaser.Physics.Impact.Body)} * @type {?(object|Phaser.Physics.Arcade.Body|MatterJS.BodyType)}
* @default null * @default null
* @since 3.0.0 * @since 3.0.0
*/ */

View file

@ -8,14 +8,14 @@ var MATH_CONST = require('../../math/const');
var Angle = require('./Angle'); var Angle = require('./Angle');
/** /**
* [description] * Returns the x component of the normal vector of the given line.
* *
* @function Phaser.Geom.Line.NormalX * @function Phaser.Geom.Line.NormalX
* @since 3.0.0 * @since 3.0.0
* *
* @param {Phaser.Geom.Line} line - The Line object to get the normal value from. * @param {Phaser.Geom.Line} line - The Line object to get the normal value from.
* *
* @return {number} [description] * @return {number} The x component of the normal vector of the line.
*/ */
var NormalX = function (line) var NormalX = function (line)
{ {

View file

@ -15,10 +15,10 @@ var Point = require('./Point');
* *
* @generic {Phaser.Geom.Point} O - [out,$return] * @generic {Phaser.Geom.Point} O - [out,$return]
* *
* @param {Phaser.Geom.Point[]} points - [description] * @param {Phaser.Types.Math.Vector2Like[]} points - An array of Vector2Like objects to get the geometric center of.
* @param {Phaser.Geom.Point} [out] - [description] * @param {Phaser.Geom.Point} [out] - A Point object to store the output coordinates in. If not given, a new Point instance is created.
* *
* @return {Phaser.Geom.Point} [description] * @return {Phaser.Geom.Point} A Point object representing the geometric center of the given points.
*/ */
var GetCentroid = function (points, out) var GetCentroid = function (points, out)
{ {

View file

@ -14,10 +14,10 @@ var Rectangle = require('../rectangle/Rectangle');
* *
* @generic {Phaser.Geom.Rectangle} O - [out,$return] * @generic {Phaser.Geom.Rectangle} O - [out,$return]
* *
* @param {Phaser.Geom.Point[]} points - [description] * @param {Phaser.Types.Math.Vector2Like[]} points - An array of Vector2Like objects to get the AABB from.
* @param {Phaser.Geom.Rectangle} [out] - [description] * @param {Phaser.Geom.Rectangle} [out] - A Rectangle object to store the results in. If not given, a new Rectangle instance is created.
* *
* @return {Phaser.Geom.Rectangle} [description] * @return {Phaser.Geom.Rectangle} A Rectangle object holding the AABB values for the given points.
*/ */
var GetRectangleFromPoints = function (points, out) var GetRectangleFromPoints = function (points, out)
{ {

View file

@ -7,7 +7,7 @@
var Point = require('./Point'); var Point = require('./Point');
/** /**
* [description] * Returns the linear interpolation point between the two given points, based on `t`.
* *
* @function Phaser.Geom.Point.Interpolate * @function Phaser.Geom.Point.Interpolate
* @since 3.0.0 * @since 3.0.0

View file

@ -8,18 +8,19 @@ var Point = require('./Point');
var GetMagnitudeSq = require('./GetMagnitudeSq'); var GetMagnitudeSq = require('./GetMagnitudeSq');
/** /**
* [description] * Calculates the vector projection of `pointA` onto the nonzero `pointB`. This is the
* orthogonal projection of `pointA` onto a straight line paralle to `pointB`.
* *
* @function Phaser.Geom.Point.Project * @function Phaser.Geom.Point.Project
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.Geom.Point} O - [out,$return] * @generic {Phaser.Geom.Point} O - [out,$return]
* *
* @param {Phaser.Geom.Point} pointA - [description] * @param {Phaser.Geom.Point} pointA - Point A, to be projected onto Point B.
* @param {Phaser.Geom.Point} pointB - [description] * @param {Phaser.Geom.Point} pointB - Point B, to have Point A projected upon it.
* @param {Phaser.Geom.Point} [out] - [description] * @param {Phaser.Geom.Point} [out] - The Point object to store the position in. If not given, a new Point instance is created.
* *
* @return {Phaser.Geom.Point} [description] * @return {Phaser.Geom.Point} A Point object holding the coordinates of the vector projection of `pointA` onto `pointB`.
*/ */
var Project = function (pointA, pointB, out) var Project = function (pointA, pointB, out)
{ {

View file

@ -7,18 +7,19 @@
var Point = require('./Point'); var Point = require('./Point');
/** /**
* [description] * Calculates the vector projection of `pointA` onto the nonzero `pointB`. This is the
* orthogonal projection of `pointA` onto a straight line paralle to `pointB`.
* *
* @function Phaser.Geom.Point.ProjectUnit * @function Phaser.Geom.Point.ProjectUnit
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.Geom.Point} O - [out,$return] * @generic {Phaser.Geom.Point} O - [out,$return]
* *
* @param {Phaser.Geom.Point} pointA - [description] * @param {Phaser.Geom.Point} pointA - Point A, to be projected onto Point B. Must be a normalized point with a magnitude of 1.
* @param {Phaser.Geom.Point} pointB - [description] * @param {Phaser.Geom.Point} pointB - Point B, to have Point A projected upon it.
* @param {Phaser.Geom.Point} [out] - [description] * @param {Phaser.Geom.Point} [out] - The Point object to store the position in. If not given, a new Point instance is created.
* *
* @return {Phaser.Geom.Point} [description] * @return {Phaser.Geom.Point} A unit Point object holding the coordinates of the vector projection of `pointA` onto `pointB`.
*/ */
var ProjectUnit = function (pointA, pointB, out) var ProjectUnit = function (pointA, pointB, out)
{ {

View file

@ -7,15 +7,15 @@
var Contains = require('./Contains'); var Contains = require('./Contains');
/** /**
* [description] * Checks the given Point again the Polygon to see if the Point lays within its vertices.
* *
* @function Phaser.Geom.Polygon.ContainsPoint * @function Phaser.Geom.Polygon.ContainsPoint
* @since 3.0.0 * @since 3.0.0
* *
* @param {Phaser.Geom.Polygon} polygon - [description] * @param {Phaser.Geom.Polygon} polygon - The Polygon to check.
* @param {Phaser.Geom.Point} point - [description] * @param {Phaser.Geom.Point} point - The Point to check if it's within the Polygon.
* *
* @return {boolean} [description] * @return {boolean} `true` if the Point is within the Polygon, otherwise `false`.
*/ */
var ContainsPoint = function (polygon, point) var ContainsPoint = function (polygon, point)
{ {

View file

@ -8,18 +8,22 @@ var Perimeter = require('./Perimeter');
var Point = require('../point/Point'); var Point = require('../point/Point');
/** /**
* Position is a value between 0 and 1 where 0 = the top-left of the rectangle and 0.5 = the bottom right. * Calculates the coordinates of a point at a certain `position` on the Rectangle's perimeter.
*
* The `position` is a fraction between 0 and 1 which defines how far into the perimeter the point is.
*
* A value of 0 or 1 returns the point at the top left corner of the rectangle, while a value of 0.5 returns the point at the bottom right corner of the rectangle. Values between 0 and 0.5 are on the top or the right side and values between 0.5 and 1 are on the bottom or the left side.
* *
* @function Phaser.Geom.Rectangle.GetPoint * @function Phaser.Geom.Rectangle.GetPoint
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.Geom.Point} O - [out,$return] * @generic {Phaser.Geom.Point} O - [out,$return]
* *
* @param {Phaser.Geom.Rectangle} rectangle - [description] * @param {Phaser.Geom.Rectangle} rectangle - The Rectangle to get the perimeter point from.
* @param {number} position - [description] * @param {number} position - The normalized distance into the Rectangle's perimeter to return.
* @param {(Phaser.Geom.Point|object)} [out] - [description] * @param {(Phaser.Geom.Point|object)} [out] - An object to update with the `x` and `y` coordinates of the point.
* *
* @return {Phaser.Geom.Point} [description] * @return {Phaser.Geom.Point} The updated `output` object, or a new Point if no `output` object was given.
*/ */
var GetPoint = function (rectangle, position, out) var GetPoint = function (rectangle, position, out)
{ {

View file

@ -8,18 +8,18 @@ var Point = require('../point/Point');
/** /**
* The size of the Rectangle object, expressed as a Point object * Returns the size of the Rectangle, expressed as a Point object.
* with the values of the width and height properties. * With the value of the `width` as the `x` property and the `height` as the `y` property.
* *
* @function Phaser.Geom.Rectangle.GetSize * @function Phaser.Geom.Rectangle.GetSize
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.Geom.Point} O - [out,$return] * @generic {Phaser.Geom.Point} O - [out,$return]
* *
* @param {Phaser.Geom.Rectangle} rect - [description] * @param {Phaser.Geom.Rectangle} rect - The Rectangle to get the size from.
* @param {(Phaser.Geom.Point|object)} [out] - [description] * @param {(Phaser.Geom.Point|object)} [out] - The Point object to store the size in. If not given, a new Point instance is created.
* *
* @return {(Phaser.Geom.Point|object)} [description] * @return {(Phaser.Geom.Point|object)} A Point object where `x` holds the width and `y` holds the height of the Rectangle.
*/ */
var GetSize = function (rect, out) var GetSize = function (rect, out)
{ {

View file

@ -9,20 +9,20 @@ var Point = require('../point/Point');
/** /**
* Return an array of points from the perimeter of the rectangle * Returns an array of points from the perimeter of the Rectangle, where each point is spaced out based
* each spaced out based on the quantity or step required * on either the `step` value, or the `quantity`.
* *
* @function Phaser.Geom.Rectangle.MarchingAnts * @function Phaser.Geom.Rectangle.MarchingAnts
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.Geom.Point[]} O - [out,$return] * @generic {Phaser.Geom.Point[]} O - [out,$return]
* *
* @param {Phaser.Geom.Rectangle} rect - [description] * @param {Phaser.Geom.Rectangle} rect - The Rectangle to get the perimeter points from.
* @param {number} step - [description] * @param {number} [step] - The distance between each point of the perimeter. Set to `null` if you wish to use the `quantity` parameter instead.
* @param {integer} quantity - [description] * @param {integer} [quantity] - The total number of points to return. The step is then calculated based on the length of the Rectangle, divided by this value.
* @param {(array|Phaser.Geom.Point[])} [out] - [description] * @param {(array|Phaser.Geom.Point[])} [out] - An array in which the perimeter points will be stored. If not given, a new array instance is created.
* *
* @return {(array|Phaser.Geom.Point[])} [description] * @return {(array|Phaser.Geom.Point[])} An array containing the perimeter points from the Rectangle.
*/ */
var MarchingAnts = function (rect, step, quantity, out) var MarchingAnts = function (rect, step, quantity, out)
{ {

View file

@ -8,18 +8,18 @@ var Point = require('../point/Point');
var DegToRad = require('../../math/DegToRad'); var DegToRad = require('../../math/DegToRad');
/** /**
* [description] * Returns a Point from the perimeter of a Rectangle based on the given angle.
* *
* @function Phaser.Geom.Rectangle.PerimeterPoint * @function Phaser.Geom.Rectangle.PerimeterPoint
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.Geom.Point} O - [out,$return] * @generic {Phaser.Geom.Point} O - [out,$return]
* *
* @param {Phaser.Geom.Rectangle} rectangle - [description] * @param {Phaser.Geom.Rectangle} rectangle - The Rectangle to get the perimeter point from.
* @param {integer} angle - [description] * @param {integer} angle - The angle of the point, in degrees.
* @param {Phaser.Geom.Point} [out] - [description] * @param {Phaser.Geom.Point} [out] - The Point object to store the position in. If not given, a new Point instance is created.
* *
* @return {Phaser.Geom.Point} [description] * @return {Phaser.Geom.Point} A Point object holding the coordinates of the Rectangle perimeter.
*/ */
var PerimeterPoint = function (rectangle, angle, out) var PerimeterPoint = function (rectangle, angle, out)
{ {

View file

@ -8,7 +8,8 @@ var EarCut = require('../polygon/Earcut');
var Triangle = require('./Triangle'); var Triangle = require('./Triangle');
/** /**
* [description] * Takes an array of vertex coordinates, and optionally an array of hole indices, then returns an array
* of Triangle instances, where the given vertices have been decomposed into a series of triangles.
* *
* @function Phaser.Geom.Triangle.BuildFromPolygon * @function Phaser.Geom.Triangle.BuildFromPolygon
* @since 3.0.0 * @since 3.0.0
@ -17,11 +18,11 @@ var Triangle = require('./Triangle');
* *
* @param {array} data - A flat array of vertex coordinates like [x0,y0, x1,y1, x2,y2, ...] * @param {array} data - A flat array of vertex coordinates like [x0,y0, x1,y1, x2,y2, ...]
* @param {array} [holes=null] - An array of hole indices if any (e.g. [5, 8] for a 12-vertex input would mean one hole with vertices 57 and another with 811). * @param {array} [holes=null] - An array of hole indices if any (e.g. [5, 8] for a 12-vertex input would mean one hole with vertices 57 and another with 811).
* @param {number} [scaleX=1] - [description] * @param {number} [scaleX=1] - Horizontal scale factor to multiply the resulting points by.
* @param {number} [scaleY=1] - [description] * @param {number} [scaleY=1] - Vertical scale factor to multiply the resulting points by.
* @param {(array|Phaser.Geom.Triangle[])} [out] - [description] * @param {(array|Phaser.Geom.Triangle[])} [out] - An array to store the resulting Triangle instances in. If not provided, a new array is created.
* *
* @return {(array|Phaser.Geom.Triangle[])} [description] * @return {(array|Phaser.Geom.Triangle[])} An array of Triangle instances, where each triangle is based on the decomposed vertices data.
*/ */
var BuildFromPolygon = function (data, holes, scaleX, scaleY, out) var BuildFromPolygon = function (data, holes, scaleX, scaleY, out)
{ {

View file

@ -39,10 +39,10 @@ function det (m00, m01, m10, m11)
* *
* @generic {Phaser.Math.Vector2} O - [out,$return] * @generic {Phaser.Math.Vector2} O - [out,$return]
* *
* @param {Phaser.Geom.Triangle} triangle - [description] * @param {Phaser.Geom.Triangle} triangle - The Triangle to get the circumcenter of.
* @param {Phaser.Math.Vector2} [out] - [description] * @param {Phaser.Math.Vector2} [out] - The Vector2 object to store the position in. If not given, a new Vector2 instance is created.
* *
* @return {Phaser.Math.Vector2} [description] * @return {Phaser.Math.Vector2} A Vector2 object holding the coordinates of the circumcenter of the Triangle.
*/ */
var CircumCenter = function (triangle, out) var CircumCenter = function (triangle, out)
{ {

View file

@ -6,17 +6,16 @@
var Length = require('../line/Length'); var Length = require('../line/Length');
// The 2D area of a triangle. The area value is always non-negative.
/** /**
* Gets the length of the perimeter of the given triangle. * Gets the length of the perimeter of the given triangle.
* Calculated by adding together the length of each of the three sides.
* *
* @function Phaser.Geom.Triangle.Perimeter * @function Phaser.Geom.Triangle.Perimeter
* @since 3.0.0 * @since 3.0.0
* *
* @param {Phaser.Geom.Triangle} triangle - [description] * @param {Phaser.Geom.Triangle} triangle - The Triangle to get the length from.
* *
* @return {number} [description] * @return {number} The length of the Triangle.
*/ */
var Perimeter = function (triangle) var Perimeter = function (triangle)
{ {

View file

@ -7,17 +7,17 @@
var Point = require('../point/Point'); var Point = require('../point/Point');
/** /**
* [description] * Returns a random Point from within the area of the given Triangle.
* *
* @function Phaser.Geom.Triangle.Random * @function Phaser.Geom.Triangle.Random
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.Geom.Point} O - [out,$return] * @generic {Phaser.Geom.Point} O - [out,$return]
* *
* @param {Phaser.Geom.Triangle} triangle - [description] * @param {Phaser.Geom.Triangle} triangle - The Triangle to get a random point from.
* @param {Phaser.Geom.Point} [out] - [description] * @param {Phaser.Geom.Point} [out] - The Point object to store the position in. If not given, a new Point instance is created.
* *
* @return {Phaser.Geom.Point} [description] * @return {Phaser.Geom.Point} A Point object holding the coordinates of a random position within the Triangle.
*/ */
var Random = function (triangle, out) var Random = function (triangle, out)
{ {

View file

@ -7,15 +7,15 @@
var Factorial = require('./Factorial'); var Factorial = require('./Factorial');
/** /**
* [description] * Calculates the Bernstein basis from the three factorial coefficients.
* *
* @function Phaser.Math.Bernstein * @function Phaser.Math.Bernstein
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} n - [description] * @param {number} n - The first value.
* @param {number} i - [description] * @param {number} i - The second value.
* *
* @return {number} [description] * @return {number} The Bernstein basis of Factorial(n) / Factorial(i) / Factorial(n - i)
*/ */
var Bernstein = function (n, i) var Bernstein = function (n, i)
{ {

View file

@ -5,16 +5,16 @@
*/ */
/** /**
* Calculates a Catmull-Rom value. * Calculates a Catmull-Rom value from the given points, based on an alpha of 0.5.
* *
* @function Phaser.Math.CatmullRom * @function Phaser.Math.CatmullRom
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} t - [description] * @param {number} t - The amount to interpolate by.
* @param {number} p0 - [description] * @param {number} p0 - The first control point.
* @param {number} p1 - [description] * @param {number} p1 - The second control point.
* @param {number} p2 - [description] * @param {number} p2 - The third control point.
* @param {number} p3 - [description] * @param {number} p3 - The fourth control point.
* *
* @return {number} The Catmull-Rom value. * @return {number} The Catmull-Rom value.
*/ */

View file

@ -508,12 +508,12 @@ var Matrix3 = new Class({
}, },
/** /**
* [description] * Set the values of this Matrix3 to be normalized from the given Matrix4.
* *
* @method Phaser.Math.Matrix3#normalFromMat4 * @method Phaser.Math.Matrix3#normalFromMat4
* @since 3.0.0 * @since 3.0.0
* *
* @param {Phaser.Math.Matrix4} m - [description] * @param {Phaser.Math.Matrix4} m - The Matrix4 to normalize the values from.
* *
* @return {Phaser.Math.Matrix3} This Matrix3. * @return {Phaser.Math.Matrix3} This Matrix3.
*/ */

View file

@ -559,12 +559,12 @@ var Matrix4 = new Class({
}, },
/** /**
* [description] * Multiply the values of this Matrix4 by those given in the `src` argument.
* *
* @method Phaser.Math.Matrix4#multiplyLocal * @method Phaser.Math.Matrix4#multiplyLocal
* @since 3.0.0 * @since 3.0.0
* *
* @param {Phaser.Math.Matrix4} src - [description] * @param {Phaser.Math.Matrix4} src - The source Matrix4 that this Matrix4 is multiplied by.
* *
* @return {Phaser.Math.Matrix4} This Matrix4. * @return {Phaser.Math.Matrix4} This Matrix4.
*/ */
@ -1356,9 +1356,9 @@ var Matrix4 = new Class({
* @method Phaser.Math.Matrix4#yawPitchRoll * @method Phaser.Math.Matrix4#yawPitchRoll
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} yaw - [description] * @param {number} yaw - The yaw value.
* @param {number} pitch - [description] * @param {number} pitch - The pitch value.
* @param {number} roll - [description] * @param {number} roll - The roll value.
* *
* @return {Phaser.Math.Matrix4} This Matrix4. * @return {Phaser.Math.Matrix4} This Matrix4.
*/ */

View file

@ -317,13 +317,13 @@ var Quaternion = new Class({
}, },
/** /**
* [description] * Rotates this Quaternion based on the two given vectors.
* *
* @method Phaser.Math.Quaternion#rotationTo * @method Phaser.Math.Quaternion#rotationTo
* @since 3.0.0 * @since 3.0.0
* *
* @param {Phaser.Math.Vector3} a - [description] * @param {Phaser.Math.Vector3} a - The transform rotation vector.
* @param {Phaser.Math.Vector3} b - [description] * @param {Phaser.Math.Vector3} b - The target rotation vector.
* *
* @return {Phaser.Math.Quaternion} This Quaternion. * @return {Phaser.Math.Quaternion} This Quaternion.
*/ */

View file

@ -33,8 +33,8 @@ var Body = new Class({
function Body (world, gameObject) function Body (world, gameObject)
{ {
var width = (gameObject.width) ? gameObject.width : 64; var width = (gameObject.displayWidth) ? gameObject.displayWidth : 64;
var height = (gameObject.height) ? gameObject.height : 64; var height = (gameObject.displayHeight) ? gameObject.displayHeight : 64;
/** /**
* The Arcade Physics simulation this Body belongs to. * The Arcade Physics simulation this Body belongs to.
@ -148,7 +148,10 @@ var Body = new Class({
* @type {Phaser.Math.Vector2} * @type {Phaser.Math.Vector2}
* @since 3.0.0 * @since 3.0.0
*/ */
this.position = new Vector2(gameObject.x, gameObject.y); this.position = new Vector2(
gameObject.x - gameObject.scaleX * gameObject.displayOriginX,
gameObject.y - gameObject.scaleY * gameObject.displayOriginY
);
/** /**
* The position of this Body during the previous step. * The position of this Body during the previous step.
@ -278,7 +281,7 @@ var Body = new Class({
* @type {Phaser.Math.Vector2} * @type {Phaser.Math.Vector2}
* @since 3.0.0 * @since 3.0.0
*/ */
this.center = new Vector2(gameObject.x + this.halfWidth, gameObject.y + this.halfHeight); this.center = new Vector2(this.position.x + this.halfWidth, this.position.y + this.halfHeight);
/** /**
* The Body's velocity, in pixels per second. * The Body's velocity, in pixels per second.
@ -904,23 +907,27 @@ var Body = new Class({
resetFlags: function () resetFlags: function ()
{ {
// Store and reset collision flags // Store and reset collision flags
this.wasTouching.none = this.touching.none; var wasTouching = this.wasTouching;
this.wasTouching.up = this.touching.up; var touching = this.touching;
this.wasTouching.down = this.touching.down; var blocked = this.blocked;
this.wasTouching.left = this.touching.left;
this.wasTouching.right = this.touching.right;
this.touching.none = true; wasTouching.none = touching.none;
this.touching.up = false; wasTouching.up = touching.up;
this.touching.down = false; wasTouching.down = touching.down;
this.touching.left = false; wasTouching.left = touching.left;
this.touching.right = false; wasTouching.right = touching.right;
this.blocked.none = true; touching.none = true;
this.blocked.up = false; touching.up = false;
this.blocked.down = false; touching.down = false;
this.blocked.left = false; touching.left = false;
this.blocked.right = false; touching.right = false;
blocked.none = true;
blocked.up = false;
blocked.down = false;
blocked.left = false;
blocked.right = false;
this.overlapR = 0; this.overlapR = 0;
this.overlapX = 0; this.overlapX = 0;
@ -1233,10 +1240,10 @@ var Body = new Class({
if (center && gameObject.getCenter) if (center && gameObject.getCenter)
{ {
var ox = gameObject.displayWidth / 2; var ox = (gameObject.width - width) / 2;
var oy = gameObject.displayHeight / 2; var oy = (gameObject.height - height) / 2;
this.offset.set(ox - this.halfWidth, oy - this.halfHeight); this.offset.set(ox, oy);
} }
this.isCircle = false; this.isCircle = false;

View file

@ -15,7 +15,7 @@ var Vector2 = require('../../math/Vector2');
* A Static Arcade Physics Body. * A Static Arcade Physics Body.
* *
* A Static Body never moves, and isn't automatically synchronized with its parent Game Object. * A Static Body never moves, and isn't automatically synchronized with its parent Game Object.
* That means if you make any change to the parent's origin, position, or scale after creating or adding the body, you'll need to update the Body manually. * That means if you make any change to the parent's origin, position, or scale after creating or adding the body, you'll need to update the Static Body manually.
* *
* A Static Body can collide with other Bodies, but is never moved by collisions. * A Static Body can collide with other Bodies, but is never moved by collisions.
* *
@ -35,8 +35,8 @@ var StaticBody = new Class({
function StaticBody (world, gameObject) function StaticBody (world, gameObject)
{ {
var width = (gameObject.width) ? gameObject.width : 64; var width = (gameObject.displayWidth) ? gameObject.displayWidth : 64;
var height = (gameObject.height) ? gameObject.height : 64; var height = (gameObject.displayHeight) ? gameObject.displayHeight : 64;
/** /**
* The Arcade Physics simulation this Static Body belongs to. * The Arcade Physics simulation this Static Body belongs to.
@ -95,8 +95,8 @@ var StaticBody = new Class({
this.isCircle = false; this.isCircle = false;
/** /**
* If this Static Body is circular, this is the unscaled radius of the Static Body's boundary, as set by {@link #setCircle}, in source pixels. * If this Static Body is circular, this is the radius of the boundary, as set by {@link Phaser.Physics.Arcade.StaticBody#setCircle}, in pixels.
* The true radius is equal to `halfWidth`. * Equal to `halfWidth`.
* *
* @name Phaser.Physics.Arcade.StaticBody#radius * @name Phaser.Physics.Arcade.StaticBody#radius
* @type {number} * @type {number}
@ -106,12 +106,13 @@ var StaticBody = new Class({
this.radius = 0; this.radius = 0;
/** /**
* The offset of this Static Body's actual position from any updated position. * The offset set by {@link Phaser.Physics.Arcade.StaticBody#setCircle} or {@link Phaser.Physics.Arcade.StaticBody#setSize}.
* *
* Unlike a dynamic Body, a Static Body does not follow its Game Object. As such, this offset is only applied when resizing the Static Body. * This doesn't affect the Static Body's position, because a Static Body does not follow its Game Object.
* *
* @name Phaser.Physics.Arcade.StaticBody#offset * @name Phaser.Physics.Arcade.StaticBody#offset
* @type {Phaser.Math.Vector2} * @type {Phaser.Math.Vector2}
* @readonly
* @since 3.0.0 * @since 3.0.0
*/ */
this.offset = new Vector2(); this.offset = new Vector2();
@ -173,7 +174,7 @@ var StaticBody = new Class({
* @type {Phaser.Math.Vector2} * @type {Phaser.Math.Vector2}
* @since 3.0.0 * @since 3.0.0
*/ */
this.center = new Vector2(gameObject.x + this.halfWidth, gameObject.y + this.halfHeight); this.center = new Vector2(this.position.x + this.halfWidth, this.position.y + this.halfHeight);
/** /**
* A constant zero velocity used by the Arcade Physics simulation for calculations. * A constant zero velocity used by the Arcade Physics simulation for calculations.
@ -389,7 +390,7 @@ var StaticBody = new Class({
this.physicsType = CONST.STATIC_BODY; this.physicsType = CONST.STATIC_BODY;
/** /**
* The calculated change in the Body's horizontal position during the current step. * The calculated change in the Static Body's horizontal position during the current step.
* For a static body this is always zero. * For a static body this is always zero.
* *
* @name Phaser.Physics.Arcade.StaticBody#_dx * @name Phaser.Physics.Arcade.StaticBody#_dx
@ -401,7 +402,7 @@ var StaticBody = new Class({
this._dx = 0; this._dx = 0;
/** /**
* The calculated change in the Body's vertical position during the current step. * The calculated change in the Static Body's vertical position during the current step.
* For a static body this is always zero. * For a static body this is always zero.
* *
* @name Phaser.Physics.Arcade.StaticBody#_dy * @name Phaser.Physics.Arcade.StaticBody#_dy
@ -450,7 +451,7 @@ var StaticBody = new Class({
}, },
/** /**
* Syncs the Body's position and size with its parent Game Object. * Syncs the Static Body's position and size with its parent Game Object.
* *
* @method Phaser.Physics.Arcade.StaticBody#updateFromGameObject * @method Phaser.Physics.Arcade.StaticBody#updateFromGameObject
* @since 3.1.0 * @since 3.1.0
@ -479,13 +480,13 @@ var StaticBody = new Class({
}, },
/** /**
* Sets the offset of the body. * Positions the Static Body at an offset from its Game Object.
* *
* @method Phaser.Physics.Arcade.StaticBody#setOffset * @method Phaser.Physics.Arcade.StaticBody#setOffset
* @since 3.4.0 * @since 3.4.0
* *
* @param {number} x - The horizontal offset of the Body from the Game Object's center. * @param {number} x - The horizontal offset of the Static Body from the Game Object's `x`.
* @param {number} y - The vertical offset of the Body from the Game Object's center. * @param {number} y - The vertical offset of the Static Body from the Game Object's `y`.
* *
* @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object.
*/ */
@ -511,15 +512,16 @@ var StaticBody = new Class({
}, },
/** /**
* Sets the size of the body. * Sets the size of the Static Body.
* When `center` is true, also repositions it.
* Resets the width and height to match current frame, if no width and height provided and a frame is found. * Resets the width and height to match current frame, if no width and height provided and a frame is found.
* *
* @method Phaser.Physics.Arcade.StaticBody#setSize * @method Phaser.Physics.Arcade.StaticBody#setSize
* @since 3.0.0 * @since 3.0.0
* *
* @param {integer} [width] - The width of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame width. * @param {integer} [width] - The width of the Static Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame width.
* @param {integer} [height] - The height of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame height. * @param {integer} [height] - The height of the Static Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame height.
* @param {boolean} [center=true] - Modify the Body's `offset`, placing the Body's center on its Game Object's center. Only works if the Game Object has the `getCenter` method. * @param {boolean} [center=true] - Place the Static Body's center on its Game Object's center. Only works if the Game Object has the `getCenter` method.
* *
* @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object.
*/ */
@ -572,7 +574,7 @@ var StaticBody = new Class({
}, },
/** /**
* Sets this Static Body to have a circular body and sets its sizes and position. * Sets this Static Body to have a circular body and sets its size and position.
* *
* @method Phaser.Physics.Arcade.StaticBody#setCircle * @method Phaser.Physics.Arcade.StaticBody#setCircle
* @since 3.0.0 * @since 3.0.0

View file

@ -15,7 +15,6 @@
module.exports = { module.exports = {
Arcade: require('./arcade'), Arcade: require('./arcade'),
Impact: require('./impact'),
Matter: require('./matter-js') Matter: require('./matter-js')
}; };

View file

@ -22,7 +22,7 @@ module.exports = {
* @param {number} b - Blue component in a range from 0.0 to 1.0 * @param {number} b - Blue component in a range from 0.0 to 1.0
* @param {number} a - Alpha component in a range from 0.0 to 1.0 * @param {number} a - Alpha component in a range from 0.0 to 1.0
* *
* @return {number} [description] * @return {number} The packed RGBA values as a Uint32.
*/ */
getTintFromFloats: function (r, g, b, a) getTintFromFloats: function (r, g, b, a)
{ {

View file

@ -2547,14 +2547,16 @@ var WebGLRenderer = new Class({
}, },
/** /**
* [description] * Sets a 1f uniform value on the given shader.
*
* If the shader is not currently active, it is made active first.
* *
* @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat1 * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat1
* @since 3.0.0 * @since 3.0.0
* *
* @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up.
* @param {string} name - The name of the uniform to look-up and modify. * @param {string} name - The name of the uniform to look-up and modify.
* @param {number} x - [description] * @param {number} x - The 1f value to set on the named uniform.
* *
* @return {this} This WebGL Renderer instance. * @return {this} This WebGL Renderer instance.
*/ */
@ -2568,15 +2570,17 @@ var WebGLRenderer = new Class({
}, },
/** /**
* [description] * Sets the 2f uniform values on the given shader.
*
* If the shader is not currently active, it is made active first.
* *
* @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat2 * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat2
* @since 3.0.0 * @since 3.0.0
* *
* @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up.
* @param {string} name - The name of the uniform to look-up and modify. * @param {string} name - The name of the uniform to look-up and modify.
* @param {number} x - [description] * @param {number} x - The 2f x value to set on the named uniform.
* @param {number} y - [description] * @param {number} y - The 2f y value to set on the named uniform.
* *
* @return {this} This WebGL Renderer instance. * @return {this} This WebGL Renderer instance.
*/ */
@ -2590,16 +2594,18 @@ var WebGLRenderer = new Class({
}, },
/** /**
* [description] * Sets the 3f uniform values on the given shader.
*
* If the shader is not currently active, it is made active first.
* *
* @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat3 * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat3
* @since 3.0.0 * @since 3.0.0
* *
* @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up.
* @param {string} name - The name of the uniform to look-up and modify. * @param {string} name - The name of the uniform to look-up and modify.
* @param {number} x - [description] * @param {number} x - The 3f x value to set on the named uniform.
* @param {number} y - [description] * @param {number} y - The 3f y value to set on the named uniform.
* @param {number} z - [description] * @param {number} z - The 3f z value to set on the named uniform.
* *
* @return {this} This WebGL Renderer instance. * @return {this} This WebGL Renderer instance.
*/ */
@ -2613,17 +2619,19 @@ var WebGLRenderer = new Class({
}, },
/** /**
* Sets uniform of a WebGLProgram * Sets the 4f uniform values on the given shader.
*
* If the shader is not currently active, it is made active first.
* *
* @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat4 * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat4
* @since 3.0.0 * @since 3.0.0
* *
* @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up.
* @param {string} name - The name of the uniform to look-up and modify. * @param {string} name - The name of the uniform to look-up and modify.
* @param {number} x - X component * @param {number} x - The 4f x value to set on the named uniform.
* @param {number} y - Y component * @param {number} y - The 4f y value to set on the named uniform.
* @param {number} z - Z component * @param {number} z - The 4f z value to set on the named uniform.
* @param {number} w - W component * @param {number} w - The 4f w value to set on the named uniform.
* *
* @return {this} This WebGL Renderer instance. * @return {this} This WebGL Renderer instance.
*/ */
@ -2637,7 +2645,9 @@ var WebGLRenderer = new Class({
}, },
/** /**
* Sets the value of a uniform variable in the given WebGLProgram. * Sets the value of a 1fv uniform variable in the given WebGLProgram.
*
* If the shader is not currently active, it is made active first.
* *
* @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat1v * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat1v
* @since 3.13.0 * @since 3.13.0
@ -2658,7 +2668,9 @@ var WebGLRenderer = new Class({
}, },
/** /**
* Sets the value of a uniform variable in the given WebGLProgram. * Sets the value of a 2fv uniform variable in the given WebGLProgram.
*
* If the shader is not currently active, it is made active first.
* *
* @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat2v * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat2v
* @since 3.13.0 * @since 3.13.0
@ -2679,7 +2691,9 @@ var WebGLRenderer = new Class({
}, },
/** /**
* Sets the value of a uniform variable in the given WebGLProgram. * Sets the value of a 3fv uniform variable in the given WebGLProgram.
*
* If the shader is not currently active, it is made active first.
* *
* @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat3v * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat3v
* @since 3.13.0 * @since 3.13.0
@ -2700,7 +2714,9 @@ var WebGLRenderer = new Class({
}, },
/** /**
* Sets the value of a uniform variable in the given WebGLProgram. * Sets the value of a 4fv uniform variable in the given WebGLProgram.
*
* If the shader is not currently active, it is made active first.
* *
* @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat4v * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat4v
* @since 3.13.0 * @since 3.13.0
@ -2722,14 +2738,16 @@ var WebGLRenderer = new Class({
}, },
/** /**
* Sets the value of a uniform variable in the given WebGLProgram. * Sets a 1i uniform value on the given shader.
*
* If the shader is not currently active, it is made active first.
* *
* @method Phaser.Renderer.WebGL.WebGLRenderer#setInt1 * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt1
* @since 3.0.0 * @since 3.0.0
* *
* @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up.
* @param {string} name - The name of the uniform to look-up and modify. * @param {string} name - The name of the uniform to look-up and modify.
* @param {integer} x - [description] * @param {integer} x - The 1i value to set on the named uniform.
* *
* @return {this} This WebGL Renderer instance. * @return {this} This WebGL Renderer instance.
*/ */
@ -2743,15 +2761,17 @@ var WebGLRenderer = new Class({
}, },
/** /**
* Sets the value of a uniform variable in the given WebGLProgram. * Sets the 2i uniform values on the given shader.
*
* If the shader is not currently active, it is made active first.
* *
* @method Phaser.Renderer.WebGL.WebGLRenderer#setInt2 * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt2
* @since 3.0.0 * @since 3.0.0
* *
* @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up.
* @param {string} name - The name of the uniform to look-up and modify. * @param {string} name - The name of the uniform to look-up and modify.
* @param {integer} x - The new X component * @param {integer} x - The 2i x value to set on the named uniform.
* @param {integer} y - The new Y component * @param {integer} y - The 2i y value to set on the named uniform.
* *
* @return {this} This WebGL Renderer instance. * @return {this} This WebGL Renderer instance.
*/ */
@ -2765,16 +2785,18 @@ var WebGLRenderer = new Class({
}, },
/** /**
* Sets the value of a uniform variable in the given WebGLProgram. * Sets the 3i uniform values on the given shader.
*
* If the shader is not currently active, it is made active first.
* *
* @method Phaser.Renderer.WebGL.WebGLRenderer#setInt3 * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt3
* @since 3.0.0 * @since 3.0.0
* *
* @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up.
* @param {string} name - The name of the uniform to look-up and modify. * @param {string} name - The name of the uniform to look-up and modify.
* @param {integer} x - The new X component * @param {integer} x - The 3i x value to set on the named uniform.
* @param {integer} y - The new Y component * @param {integer} y - The 3i y value to set on the named uniform.
* @param {integer} z - The new Z component * @param {integer} z - The 3i z value to set on the named uniform.
* *
* @return {this} This WebGL Renderer instance. * @return {this} This WebGL Renderer instance.
*/ */
@ -2788,17 +2810,19 @@ var WebGLRenderer = new Class({
}, },
/** /**
* Sets the value of a uniform variable in the given WebGLProgram. * Sets the 4i uniform values on the given shader.
*
* If the shader is not currently active, it is made active first.
* *
* @method Phaser.Renderer.WebGL.WebGLRenderer#setInt4 * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt4
* @since 3.0.0 * @since 3.0.0
* *
* @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up.
* @param {string} name - The name of the uniform to look-up and modify. * @param {string} name - The name of the uniform to look-up and modify.
* @param {integer} x - X component * @param {integer} x - The 4i x value to set on the named uniform.
* @param {integer} y - Y component * @param {integer} y - The 4i y value to set on the named uniform.
* @param {integer} z - Z component * @param {integer} z - The 4i z value to set on the named uniform.
* @param {integer} w - W component * @param {integer} w - The 4i w value to set on the named uniform.
* *
* @return {this} This WebGL Renderer instance. * @return {this} This WebGL Renderer instance.
*/ */
@ -2812,7 +2836,9 @@ var WebGLRenderer = new Class({
}, },
/** /**
* Sets the value of a 2x2 matrix uniform variable in the given WebGLProgram. * Sets the value of a matrix 2fv uniform variable in the given WebGLProgram.
*
* If the shader is not currently active, it is made active first.
* *
* @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix2 * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix2
* @since 3.0.0 * @since 3.0.0
@ -2820,7 +2846,7 @@ var WebGLRenderer = new Class({
* @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up.
* @param {string} name - The name of the uniform to look-up and modify. * @param {string} name - The name of the uniform to look-up and modify.
* @param {boolean} transpose - The value indicating whether to transpose the matrix. Must be false. * @param {boolean} transpose - The value indicating whether to transpose the matrix. Must be false.
* @param {Float32Array} matrix - The new matrix value. * @param {Float32Array} matrix - A Float32Array or sequence of 4 float values.
* *
* @return {this} This WebGL Renderer instance. * @return {this} This WebGL Renderer instance.
*/ */
@ -2834,15 +2860,17 @@ var WebGLRenderer = new Class({
}, },
/** /**
* [description] * Sets the value of a matrix 3fv uniform variable in the given WebGLProgram.
*
* If the shader is not currently active, it is made active first.
* *
* @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix3 * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix3
* @since 3.0.0 * @since 3.0.0
* *
* @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up.
* @param {string} name - The name of the uniform to look-up and modify. * @param {string} name - The name of the uniform to look-up and modify.
* @param {boolean} transpose - [description] * @param {boolean} transpose - The value indicating whether to transpose the matrix. Must be false.
* @param {Float32Array} matrix - [description] * @param {Float32Array} matrix - A Float32Array or sequence of 9 float values.
* *
* @return {this} This WebGL Renderer instance. * @return {this} This WebGL Renderer instance.
*/ */
@ -2856,15 +2884,17 @@ var WebGLRenderer = new Class({
}, },
/** /**
* Sets uniform of a WebGLProgram * Sets the value of a matrix 4fv uniform variable in the given WebGLProgram.
*
* If the shader is not currently active, it is made active first.
* *
* @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix4 * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix4
* @since 3.0.0 * @since 3.0.0
* *
* @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up.
* @param {string} name - The name of the uniform to look-up and modify. * @param {string} name - The name of the uniform to look-up and modify.
* @param {boolean} transpose - Is the matrix transposed * @param {boolean} transpose - The value indicating whether to transpose the matrix. Must be false.
* @param {Float32Array} matrix - Matrix data * @param {Float32Array} matrix - A Float32Array or sequence of 16 float values.
* *
* @return {this} This WebGL Renderer instance. * @return {this} This WebGL Renderer instance.
*/ */

View file

@ -126,21 +126,23 @@ var BitmapMaskPipeline = new Class({
}, },
/** /**
* [description] * Resizes this pipeline and updates the projection.
* *
* @method Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#resize * @method Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#resize
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} width - [description] * @param {number} width - The new width.
* @param {number} height - [description] * @param {number} height - The new height.
* @param {number} resolution - [description] * @param {number} resolution - The resolution.
* *
* @return {this} This WebGLPipeline instance. * @return {this} This WebGLPipeline instance.
*/ */
resize: function (width, height, resolution) resize: function (width, height, resolution)
{ {
WebGLPipeline.prototype.resize.call(this, width, height, resolution); WebGLPipeline.prototype.resize.call(this, width, height, resolution);
this.resolutionDirty = true; this.resolutionDirty = true;
return this; return this;
}, },
@ -153,7 +155,7 @@ var BitmapMaskPipeline = new Class({
* *
* @param {Phaser.GameObjects.GameObject} mask - GameObject used as mask. * @param {Phaser.GameObjects.GameObject} mask - GameObject used as mask.
* @param {Phaser.GameObjects.GameObject} maskedObject - GameObject masked by the mask GameObject. * @param {Phaser.GameObjects.GameObject} maskedObject - GameObject masked by the mask GameObject.
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description] * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera rendering the current mask.
*/ */
beginMask: function (mask, maskedObject, camera) beginMask: function (mask, maskedObject, camera)
{ {

View file

@ -225,16 +225,6 @@ var Scene = new Class({
*/ */
this.physics; this.physics;
/**
* A scene level Impact Physics Plugin.
* This property will only be available if defined in the Scene Injection Map, the plugin is installed and configured.
*
* @name Phaser.Scene#impact
* @type {Phaser.Physics.Impact.ImpactPhysics}
* @since 3.0.0
*/
this.impact;
/** /**
* A scene level Matter Physics Plugin. * A scene level Matter Physics Plugin.
* This property will only be available if defined in the Scene Injection Map, the plugin is installed and configured. * This property will only be available if defined in the Scene Injection Map, the plugin is installed and configured.

View file

@ -299,8 +299,8 @@ var TextureManager = new Class({
* *
* @param {string} key - The unique string-based key of the Texture. * @param {string} key - The unique string-based key of the Texture.
* @param {(string|integer)} [frame] - The string-based name, or integer based index, of the Frame to get from the Texture. * @param {(string|integer)} [frame] - The string-based name, or integer based index, of the Frame to get from the Texture.
* @param {string} [type='image/png'] - [description] * @param {string} [type='image/png'] - A DOMString indicating the image format. The default format type is image/png.
* @param {number} [encoderOptions=0.92] - [description] * @param {number} [encoderOptions=0.92] - A Number between 0 and 1 indicating the image quality to use for image formats that use lossy compression such as image/jpeg and image/webp. If this argument is anything else, the default value for image quality is used. The default value is 0.92. Other arguments are ignored.
* *
* @return {string} The base64 encoded data, or an empty string if the texture frame could not be found. * @return {string} The base64 encoded data, or an empty string if the texture frame could not be found.
*/ */
@ -443,14 +443,44 @@ var TextureManager = new Class({
/** /**
* Creates a new Texture using the given config values. * Creates a new Texture using the given config values.
*
* Generated textures consist of a Canvas element to which the texture data is drawn. * Generated textures consist of a Canvas element to which the texture data is drawn.
* See the Phaser.Create function for the more direct way to create textures. *
* Generates a texture based on the given Create configuration object.
*
* The texture is drawn using a fixed-size indexed palette of 16 colors, where the hex value in the
* data cells map to a single color. For example, if the texture config looked like this:
*
* ```javascript
* var star = [
* '.....828.....',
* '....72227....',
* '....82228....',
* '...7222227...',
* '2222222222222',
* '8222222222228',
* '.72222222227.',
* '..787777787..',
* '..877777778..',
* '.78778887787.',
* '.27887.78872.',
* '.787.....787.'
* ];
*
* this.textures.generate('star', { data: star, pixelWidth: 4 });
* ```
*
* Then it would generate a texture that is 52 x 48 pixels in size, because each cell of the data array
* represents 1 pixel multiplied by the `pixelWidth` value. The cell values, such as `8`, maps to color
* number 8 in the palette. If a cell contains a period character `.` then it is transparent.
*
* The default palette is Arne16, but you can specify your own using the `palette` property.
* *
* @method Phaser.Textures.TextureManager#generate * @method Phaser.Textures.TextureManager#generate
* @since 3.0.0 * @since 3.0.0
* *
* @param {string} key - The unique string-based key of the Texture. * @param {string} key - The unique string-based key of the Texture.
* @param {object} config - The configuration object needed to generate the texture. * @param {Phaser.Types.Create.GenerateTextureConfig} config - The configuration object needed to generate the texture.
* *
* @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use.
*/ */

View file

@ -19,15 +19,15 @@ var GetFastValue = require('../../utils/object/GetFastValue');
* *
* @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to.
* @param {integer} sourceIndex - The index of the TextureSource. * @param {integer} sourceIndex - The index of the TextureSource.
* @param {integer} x - [description] * @param {integer} x - The top-left coordinate of the Sprite Sheet. Defaults to zero. Used when extracting sheets from atlases.
* @param {integer} y - [description] * @param {integer} y - The top-left coordinate of the Sprite Sheet. Defaults to zero. Used when extracting sheets from atlases.
* @param {integer} width - [description] * @param {integer} width - The width of the source image.
* @param {integer} height - [description] * @param {integer} height - The height of the source image.
* @param {object} config - An object describing how to parse the Sprite Sheet. * @param {object} config - An object describing how to parse the Sprite Sheet.
* @param {number} config.frameWidth - Width in pixels of a single frame in the sprite sheet. * @param {number} config.frameWidth - Width in pixels of a single frame in the sprite sheet.
* @param {number} [config.frameHeight] - Height in pixels of a single frame in the sprite sheet. Defaults to frameWidth if not provided. * @param {number} [config.frameHeight] - Height in pixels of a single frame in the sprite sheet. Defaults to frameWidth if not provided.
* @param {number} [config.startFrame=0] - [description] * @param {number} [config.startFrame=0] - The frame to start extracting from. Defaults to zero.
* @param {number} [config.endFrame=-1] - [description] * @param {number} [config.endFrame=-1] - The frame to finish extracting at. Defaults to -1, which means 'all frames'.
* @param {number} [config.margin=0] - If the frames have been drawn with a margin, specify the amount here. * @param {number} [config.margin=0] - If the frames have been drawn with a margin, specify the amount here.
* @param {number} [config.spacing=0] - If the frames have been drawn with spacing between them, specify the amount here. * @param {number} [config.spacing=0] - If the frames have been drawn with spacing between them, specify the amount here.
* *

18
types/SpineFile.d.ts vendored
View file

@ -1,18 +1,18 @@
declare namespace Phaser.Loader.FileTypes { declare namespace Phaser.Loader.FileTypes {
interface SpineFileConfig { interface SpineFileConfig {
key: string key: string;
textureURL?: string textureURL?: string;
textureExtension?: string textureExtension?: string;
textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject;
normalMap?: string normalMap?: string;
atlasURL?: string atlasURL?: string;
atlasExtension?: string atlasExtension?: string;
atlasXhrSettings?: Phaser.Types.Loader.XHRSettingsObject atlasXhrSettings?: Phaser.Types.Loader.XHRSettingsObject;
} }
class SpineFile extends Phaser.Loader.MultiFile { class SpineFile extends Phaser.Loader.MultiFile {
constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Loader.FileTypes.SpineFileConfig, jsonURL: string | string[], atlasURL: string, preMultipliedAlpha: boolean, jsonXhrSettings: Phaser.Types.Loader.XHRSettingsObject, atlasXhrSettings: Phaser.Types.Loader.XHRSettingsObject) constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Loader.FileTypes.SpineFileConfig, jsonURL: string | string[], atlasURL: string, preMultipliedAlpha: boolean, jsonXhrSettings: Phaser.Types.Loader.XHRSettingsObject, atlasXhrSettings: Phaser.Types.Loader.XHRSettingsObject)
addToCache() addToCache();
} }
} }

View file

@ -1,85 +1,125 @@
/// <reference path="./spine.d.ts" /> /// <reference path="./spine.d.ts" />
/// <reference path="./SpinePlugin.d.ts" />
declare class SpineGameObject { declare class SpineGameObject extends Phaser.GameObjects.GameObject implements Omit<Phaser.GameObjects.Components.ComputedSize, 'setSize'>, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible {
constructor(scene: Phaser.Scene, pluginManager: SpinePlugin, x: number, y: number, key?: string, animationName?: string, loop?: boolean) constructor(scene: Phaser.Scene, pluginManager: SpinePlugin, x: number, y: number, key?: string, animationName?: string, loop?: boolean);
alpha: number alpha: number;
angle: integer;
readonly blendMode: number readonly blendMode: number;
blue: number blue: number;
bounds: any bounds: any;
displayOriginX: number displayOriginX: number;
displayOriginY: number displayOriginY: number;
drawDebug: boolean drawDebug: boolean;
green: number depth: number;
plugin: SpinePlugin displayWidth: number;
preMultipliedAlpha: boolean displayHeight: number;
red: number flipX: boolean;
root: spine.Bone flipY: boolean;
green: number;
height: number;
plugin: SpinePlugin;
preMultipliedAlpha: boolean;
red: number;
root: spine.Bone;
rotation: number;
scale: number;
scaleX: number scaleX: number
scaleY: number scaleY: number
skeleton: spine.Skeleton scrollFactorX: number;
skeletonData: spine.SkeletonData scrollFactorY: number;
state: spine.AnimationState skeleton: spine.Skeleton;
stateData: spine.AnimationStateData skeletonData: spine.SkeletonData;
timeScale: number // @ts-ignore - spine.AnimationState significantly different than GameObject.state
state: spine.AnimationState;
stateData: spine.AnimationStateData;
timeScale: number;
visible: boolean;
x: number;
y: number;
z: number;
w: number;
width: number;
addAnimation(trackIndex: integer, animationName: string, loop?: boolean, delay?: integer): spine.TrackEntry addAnimation(trackIndex: integer, animationName: string, loop?: boolean, delay?: integer): spine.TrackEntry;
angleBoneToXY(bone: spine.Bone, worldX: number, worldY: number, offset?: number, minAngle?: number, maxAngle?: number): SpineGameObject angleBoneToXY(bone: spine.Bone, worldX: number, worldY: number, offset?: number, minAngle?: number, maxAngle?: number): SpineGameObject;
clearTrack(trackIndex: integer): SpineGameObject clearTrack(trackIndex: integer): SpineGameObject;
clearTracks(): SpineGameObject clearTracks(): SpineGameObject;
findAnimation(animationName: string): spine.Animation findAnimation(animationName: string): spine.Animation;
findBone(boneName: string): spine.Bone findBone(boneName: string): spine.Bone;
findBoneIndex(boneName: string): number findBoneIndex(boneName: string): number;
findEvent(eventDataName: string): spine.EventData findEvent(eventDataName: string): spine.EventData;
findIkConstraint(constraintName: string): spine.IkConstraintData findIkConstraint(constraintName: string): spine.IkConstraintData;
findPathConstraint(constraintName: string): spine.PathConstraintData findPathConstraint(constraintName: string): spine.PathConstraintData;
findPathConstraintIndex(constraintName: string): number findPathConstraintIndex(constraintName: string): number;
findSkin(skinName: string): spine.Skin findSkin(skinName: string): spine.Skin;
findSlot(slotName: string): spine.Slot findSlot(slotName: string): spine.Slot;
findSlotIndex(slotName: string): number findSlotIndex(slotName: string): number;
findTransformConstraint(constraintName: string): spine.TransformConstraintData findTransformConstraint(constraintName: string): spine.TransformConstraintData;
getAnimationList(): string[] getAnimationList(): string[];
getAttachment(slotIndex: integer, attachmentName: string): spine.Attachment getAttachment(slotIndex: integer, attachmentName: string): spine.Attachment;
getAttachmentByName(slotName: string, attachmentName: string): spine.Attachment getAttachmentByName(slotName: string, attachmentName: string): spine.Attachment;
getBoneList(): string[] getBoneList(): string[];
getBounds(): any getBounds(): any;
getCurrentAnimation(trackIndex?: integer): spine.Animation getCurrentAnimation(trackIndex?: integer): spine.Animation;
getRootBone(): spine.Bone getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix;
getSkinList(): string[] getParentRotation(): number;
getSlotList(): string[] getRootBone(): spine.Bone;
play(animationName: string, loop?: boolean, ignoreIfPlaying?: boolean): SpineGameObject getSkinList(): string[];
getSlotList(): string[];
getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix;
play(animationName: string, loop?: boolean, ignoreIfPlaying?: boolean): SpineGameObject;
protected preUpdate(time: number, delta: number): void protected preUpdate(time: number, delta: number): void;
protected preDestroy(): void protected preDestroy(): void;
refresh(): SpineGameObject refresh(): SpineGameObject;
setAlpha(value?: number): SpineGameObject resetFlip(): this;
setAnimation(trackIndex: integer, animationName: string, loop?: boolean, ignoreIfPlaying?: boolean): spine.TrackEntry setAlpha(value?: number): SpineGameObject;
setAttachment(slotName: string, attachmentName: string): SpineGameObject setAngle(degrees?: number): this;
setBonesToSetupPose(): SpineGameObject setAnimation(trackIndex: integer, animationName: string, loop?: boolean, ignoreIfPlaying?: boolean): spine.TrackEntry;
setColor(color?: integer, slotName?: string): SpineGameObject setAttachment(slotName: string, attachmentName: string): SpineGameObject;
setEmptyAnimation(trackIndex: integer, mixDuration?: integer): spine.TrackEntry setBonesToSetupPose(): SpineGameObject;
setMix(fromName: string, toName: string, duration?: number): SpineGameObject setColor(color?: integer, slotName?: string): SpineGameObject;
setOffset(offsetX?: number, offsetY?: number): SpineGameObject setDepth(value: integer): this;
setSize(width?: number, height?: number, offsetX?: number, offsetY?: number): SpineGameObject setDisplaySize(width: number, height: number): this;
setSkeleton(atlasDataKey: string, skeletonJSON: object, animationName?: string, loop?: boolean): SpineGameObject setEmptyAnimation(trackIndex: integer, mixDuration?: integer): spine.TrackEntry;
setSkeletonFromJSON(atlasDataKey: string, skeletonJSON: object, animationName?: string, loop?: boolean): SpineGameObject setFlipX(value: boolean): this;
setSkin(newSkin: spine.Skin): SpineGameObject setFlipY(value: boolean): this;
setSkinByName(skinName: string): SpineGameObject setFlip(x: boolean, y: boolean): this;
setSlotsToSetupPose(): SpineGameObject setMix(fromName: string, toName: string, duration?: number): SpineGameObject;
setToSetupPose(): SpineGameObject setOffset(offsetX?: number, offsetY?: number): SpineGameObject;
updateSize(): SpineGameObject setPosition(x?: number, y?: number, z?: number, w?: number): this;
willRender(): boolean setRandomPosition(x?: number, y?: number, width?: number, height?: number): this;
setRotation(radians?: number): this;
setScale(x: number, y?: number): this;
setScrollFactor(x: number, y?: number): this;
setSize(width?: number, height?: number, offsetX?: number, offsetY?: number): SpineGameObject;
setSkeleton(atlasDataKey: string, skeletonJSON: object, animationName?: string, loop?: boolean): SpineGameObject;
setSkeletonFromJSON(atlasDataKey: string, skeletonJSON: object, animationName?: string, loop?: boolean): SpineGameObject;
setSkin(newSkin: spine.Skin): SpineGameObject;
setSkinByName(skinName: string): SpineGameObject;
setSlotsToSetupPose(): SpineGameObject;
setToSetupPose(): SpineGameObject;
setVisible(value: boolean): this;
setX(value?: number): this;
setY(value?: number): this;
setZ(value?: number): this;
setW(value?: number): this;
toggleFlipX(): this;
toggleFlipY(): this;
updateSize(): SpineGameObject;
willRender(): boolean;
} }
declare interface SpineGameObjectConfig extends Phaser.Types.GameObjects.GameObjectConfig declare interface SpineGameObjectConfig extends Phaser.Types.GameObjects.GameObjectConfig {
{ key?: string;
key?: string animationName?: string;
animationName?: string loop?: boolean;
loop?: boolean skinName?: string;
skinName?: string slotName?: string;
slotName?: string attachmentName?: string;
attachmentName?: string
} }

View file

@ -1,57 +1,59 @@
/// <reference path="./spine.d.ts" /> /// <reference path="./spine.d.ts" />
/// <reference path="./SpineFile.d.ts" />
/// <reference path="./SpineGameObject.d.ts" />
declare namespace Phaser.Loader { declare namespace Phaser.Loader {
interface LoaderPlugin extends Phaser.Events.EventEmitter { interface LoaderPlugin extends Phaser.Events.EventEmitter {
spine(key: string | Phaser.Loader.FileTypes.SpineFileConfig | Phaser.Loader.FileTypes.SpineFileConfig[], jsonURL: string, atlasURL: string | string[], preMultipliedAlpha?: boolean, textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, atlasXhrSettings?: Phaser.Types.Loader.XHRSettingsObject): LoaderPlugin spine(key: string | Phaser.Loader.FileTypes.SpineFileConfig | Phaser.Loader.FileTypes.SpineFileConfig[], jsonURL: string, atlasURL: string | string[], preMultipliedAlpha?: boolean, textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject, atlasXhrSettings?: Phaser.Types.Loader.XHRSettingsObject): LoaderPlugin;
} }
} }
declare namespace Phaser.GameObjects { declare namespace Phaser.GameObjects {
interface GameObjectFactory { interface GameObjectFactory {
spine(x: number, y: number, key?: string, aimationName?: string, loop?: boolean): SpineGameObject spine(x: number, y: number, key?: string, aimationName?: string, loop?: boolean): SpineGameObject;
} }
interface GameObjectCreator { interface GameObjectCreator {
spine(config: SpineGameObjectConfig, addToScene?: boolean): SpineGameObject spine(config: SpineGameObjectConfig, addToScene?: boolean): SpineGameObject;
} }
} }
declare class SpinePlugin extends Phaser.Plugins.ScenePlugin { declare class SpinePlugin extends Phaser.Plugins.ScenePlugin {
constructor(scene: Phaser.Scene, pluginManager: Phaser.Plugins.PluginManager) constructor(scene: Phaser.Scene, pluginManager: Phaser.Plugins.PluginManager);
readonly isWebGL: boolean readonly isWebGL: boolean;
cache: Phaser.Cache.BaseCache cache: Phaser.Cache.BaseCache;
spineTextures: Phaser.Cache.BaseCache spineTextures: Phaser.Cache.BaseCache;
json: Phaser.Cache.BaseCache json: Phaser.Cache.BaseCache;
textures: Phaser.Textures.TextureManager textures: Phaser.Textures.TextureManager;
drawDebug: boolean drawDebug: boolean;
gl: WebGLRenderingContext gl: WebGLRenderingContext;
renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer;
sceneRenderer: spine.webgl.SceneRenderer sceneRenderer: spine.webgl.SceneRenderer;
skeletonRenderer: spine.canvas.SkeletonRenderer | spine.webgl.SkeletonRenderer skeletonRenderer: spine.canvas.SkeletonRenderer | spine.webgl.SkeletonRenderer;
skeletonDebugRenderer: spine.webgl.SkeletonDebugRenderer skeletonDebugRenderer: spine.webgl.SkeletonDebugRenderer;
plugin: typeof spine plugin: typeof spine;
getAtlasCanvas(key: string): spine.TextureAtlas getAtlasCanvas(key: string): spine.TextureAtlas;
getAtlasWebGL(key: string): spine.TextureAtlas getAtlasWebGL(key: string): spine.TextureAtlas;
worldToLocal(x: number, y: number, skeleton: spine.Skeleton, bone?: spine.Bone): spine.Vector2 worldToLocal(x: number, y: number, skeleton: spine.Skeleton, bone?: spine.Bone): spine.Vector2;
getVector2(x: number, y: number): spine.Vector2 getVector2(x: number, y: number): spine.Vector2;
getVector3(x: number, y: number, z: number): spine.Vector2 getVector3(x: number, y: number, z: number): spine.Vector2;
setDebugBones(value?: boolean): SpinePlugin setDebugBones(value?: boolean): SpinePlugin;
setDebugRegionAttachments(value?: boolean): SpinePlugin setDebugRegionAttachments(value?: boolean): SpinePlugin;
setDebugBoundingBoxes(value?: boolean): SpinePlugin setDebugBoundingBoxes(value?: boolean): SpinePlugin;
setDebugMeshHull(value?: boolean): SpinePlugin setDebugMeshHull(value?: boolean): SpinePlugin;
setDebugMeshTriangles(value?: boolean): SpinePlugin setDebugMeshTriangles(value?: boolean): SpinePlugin;
setDebugPaths(value?: boolean): SpinePlugin setDebugPaths(value?: boolean): SpinePlugin;
setDebugSkeletonXY(value?: boolean): SpinePlugin setDebugSkeletonXY(value?: boolean): SpinePlugin;
setDebugClipping(value?: boolean): SpinePlugin setDebugClipping(value?: boolean): SpinePlugin;
setEffect(effect?: spine.VertexEffect): SpinePlugin setEffect(effect?: spine.VertexEffect): SpinePlugin;
createSkeleton(key: string, skeletonJSON?: object): any | null createSkeleton(key: string, skeletonJSON?: object): any | null;
createAnimationState(skeleton: spine.Skeleton): any createAnimationState(skeleton: spine.Skeleton): any;
getBounds(skeleton: spine.Skeleton): any getBounds(skeleton: spine.Skeleton): any;
onResize(): void onResize(): void;
add(x: number, y: number, key?: string, animationName?: string, loop?: boolean): SpineGameObject add(x: number, y: number, key?: string, animationName?: string, loop?: boolean): SpineGameObject;
make(config: SpineGameObjectConfig, addToScene?: boolean): SpineGameObject make(config: SpineGameObjectConfig, addToScene?: boolean): SpineGameObject;
} }