From 1dd779efcb1fc070bc186f6036ec7d8c834434c7 Mon Sep 17 00:00:00 2001 From: Tommy Leung Date: Sat, 18 Jan 2020 14:14:07 -0700 Subject: [PATCH 01/23] update SpineGameObject.d.ts - extends from Phaser.GameObjects.GameObject - implements interfaces for mixins - use Omit for setSize signature conflicts in ComputedSize - use @ts-ignore for state property conflict; spine.AnimationState significantly different than GameObject.state - added semi-colons to better match rest of defintion files --- types/SpineFile.d.ts | 18 ++-- types/SpineGameObject.d.ts | 184 ++++++++++++++++++++++--------------- types/SpinePlugin.d.ts | 74 +++++++-------- 3 files changed, 159 insertions(+), 117 deletions(-) diff --git a/types/SpineFile.d.ts b/types/SpineFile.d.ts index d2abdab1f..1a06f8bb6 100644 --- a/types/SpineFile.d.ts +++ b/types/SpineFile.d.ts @@ -1,18 +1,18 @@ declare namespace Phaser.Loader.FileTypes { interface SpineFileConfig { - key: string - textureURL?: string - textureExtension?: string - textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject - normalMap?: string - atlasURL?: string - atlasExtension?: string - atlasXhrSettings?: Phaser.Types.Loader.XHRSettingsObject + key: string; + textureURL?: string; + textureExtension?: string; + textureXhrSettings?: Phaser.Types.Loader.XHRSettingsObject; + normalMap?: string; + atlasURL?: string; + atlasExtension?: string; + atlasXhrSettings?: Phaser.Types.Loader.XHRSettingsObject; } 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) - addToCache() + addToCache(); } } diff --git a/types/SpineGameObject.d.ts b/types/SpineGameObject.d.ts index 171319d47..90fe56476 100644 --- a/types/SpineGameObject.d.ts +++ b/types/SpineGameObject.d.ts @@ -1,85 +1,125 @@ /// +/// -declare class SpineGameObject { - constructor(scene: Phaser.Scene, pluginManager: SpinePlugin, x: number, y: number, key?: string, animationName?: string, loop?: boolean) +declare class SpineGameObject extends Phaser.GameObjects.GameObject implements Omit, 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); - alpha: number + alpha: number; + angle: integer; - readonly blendMode: number + readonly blendMode: number; - blue: number - bounds: any - displayOriginX: number - displayOriginY: number - drawDebug: boolean - green: number - plugin: SpinePlugin - preMultipliedAlpha: boolean - red: number - root: spine.Bone + blue: number; + bounds: any; + displayOriginX: number; + displayOriginY: number; + drawDebug: boolean; + depth: number; + displayWidth: number; + displayHeight: number; + flipX: boolean; + flipY: boolean; + green: number; + height: number; + plugin: SpinePlugin; + preMultipliedAlpha: boolean; + red: number; + root: spine.Bone; + rotation: number; + scale: number; scaleX: number scaleY: number - skeleton: spine.Skeleton - skeletonData: spine.SkeletonData - state: spine.AnimationState - stateData: spine.AnimationStateData - timeScale: number + scrollFactorX: number; + scrollFactorY: number; + skeleton: spine.Skeleton; + skeletonData: spine.SkeletonData; + // @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 - angleBoneToXY(bone: spine.Bone, worldX: number, worldY: number, offset?: number, minAngle?: number, maxAngle?: number): SpineGameObject - clearTrack(trackIndex: integer): SpineGameObject - clearTracks(): SpineGameObject - findAnimation(animationName: string): spine.Animation - findBone(boneName: string): spine.Bone - findBoneIndex(boneName: string): number - findEvent(eventDataName: string): spine.EventData - findIkConstraint(constraintName: string): spine.IkConstraintData - findPathConstraint(constraintName: string): spine.PathConstraintData - findPathConstraintIndex(constraintName: string): number - findSkin(skinName: string): spine.Skin - findSlot(slotName: string): spine.Slot - findSlotIndex(slotName: string): number - findTransformConstraint(constraintName: string): spine.TransformConstraintData - getAnimationList(): string[] - getAttachment(slotIndex: integer, attachmentName: string): spine.Attachment - getAttachmentByName(slotName: string, attachmentName: string): spine.Attachment - getBoneList(): string[] - getBounds(): any - getCurrentAnimation(trackIndex?: integer): spine.Animation - getRootBone(): spine.Bone - getSkinList(): string[] - getSlotList(): string[] - play(animationName: string, loop?: boolean, ignoreIfPlaying?: boolean): SpineGameObject + 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; + clearTrack(trackIndex: integer): SpineGameObject; + clearTracks(): SpineGameObject; + findAnimation(animationName: string): spine.Animation; + findBone(boneName: string): spine.Bone; + findBoneIndex(boneName: string): number; + findEvent(eventDataName: string): spine.EventData; + findIkConstraint(constraintName: string): spine.IkConstraintData; + findPathConstraint(constraintName: string): spine.PathConstraintData; + findPathConstraintIndex(constraintName: string): number; + findSkin(skinName: string): spine.Skin; + findSlot(slotName: string): spine.Slot; + findSlotIndex(slotName: string): number; + findTransformConstraint(constraintName: string): spine.TransformConstraintData; + getAnimationList(): string[]; + getAttachment(slotIndex: integer, attachmentName: string): spine.Attachment; + getAttachmentByName(slotName: string, attachmentName: string): spine.Attachment; + getBoneList(): string[]; + getBounds(): any; + getCurrentAnimation(trackIndex?: integer): spine.Animation; + getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + getParentRotation(): number; + getRootBone(): spine.Bone; + 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 preDestroy(): void + protected preUpdate(time: number, delta: number): void; + protected preDestroy(): void; - refresh(): SpineGameObject - setAlpha(value?: number): SpineGameObject - setAnimation(trackIndex: integer, animationName: string, loop?: boolean, ignoreIfPlaying?: boolean): spine.TrackEntry - setAttachment(slotName: string, attachmentName: string): SpineGameObject - setBonesToSetupPose(): SpineGameObject - setColor(color?: integer, slotName?: string): SpineGameObject - setEmptyAnimation(trackIndex: integer, mixDuration?: integer): spine.TrackEntry - setMix(fromName: string, toName: string, duration?: number): SpineGameObject - setOffset(offsetX?: number, offsetY?: number): SpineGameObject - 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 - updateSize(): SpineGameObject - willRender(): boolean + refresh(): SpineGameObject; + resetFlip(): this; + setAlpha(value?: number): SpineGameObject; + setAngle(degrees?: number): this; + setAnimation(trackIndex: integer, animationName: string, loop?: boolean, ignoreIfPlaying?: boolean): spine.TrackEntry; + setAttachment(slotName: string, attachmentName: string): SpineGameObject; + setBonesToSetupPose(): SpineGameObject; + setColor(color?: integer, slotName?: string): SpineGameObject; + setDepth(value: integer): this; + setDisplaySize(width: number, height: number): this; + setEmptyAnimation(trackIndex: integer, mixDuration?: integer): spine.TrackEntry; + setFlipX(value: boolean): this; + setFlipY(value: boolean): this; + setFlip(x: boolean, y: boolean): this; + setMix(fromName: string, toName: string, duration?: number): SpineGameObject; + setOffset(offsetX?: number, offsetY?: number): SpineGameObject; + setPosition(x?: number, y?: number, z?: number, w?: number): this; + 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 -{ - key?: string - animationName?: string - loop?: boolean - skinName?: string - slotName?: string - attachmentName?: string +declare interface SpineGameObjectConfig extends Phaser.Types.GameObjects.GameObjectConfig { + key?: string; + animationName?: string; + loop?: boolean; + skinName?: string; + slotName?: string; + attachmentName?: string; } diff --git a/types/SpinePlugin.d.ts b/types/SpinePlugin.d.ts index 2e68dca5d..e65e578db 100644 --- a/types/SpinePlugin.d.ts +++ b/types/SpinePlugin.d.ts @@ -1,57 +1,59 @@ /// +/// +/// declare namespace Phaser.Loader { 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 { 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 { - spine(config: SpineGameObjectConfig, addToScene?: boolean): SpineGameObject + spine(config: SpineGameObjectConfig, addToScene?: boolean): SpineGameObject; } } 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 - spineTextures: Phaser.Cache.BaseCache - json: Phaser.Cache.BaseCache - textures: Phaser.Textures.TextureManager - drawDebug: boolean - gl: WebGLRenderingContext - renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer - sceneRenderer: spine.webgl.SceneRenderer - skeletonRenderer: spine.canvas.SkeletonRenderer | spine.webgl.SkeletonRenderer - skeletonDebugRenderer: spine.webgl.SkeletonDebugRenderer + cache: Phaser.Cache.BaseCache; + spineTextures: Phaser.Cache.BaseCache; + json: Phaser.Cache.BaseCache; + textures: Phaser.Textures.TextureManager; + drawDebug: boolean; + gl: WebGLRenderingContext; + renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; + sceneRenderer: spine.webgl.SceneRenderer; + skeletonRenderer: spine.canvas.SkeletonRenderer | spine.webgl.SkeletonRenderer; + skeletonDebugRenderer: spine.webgl.SkeletonDebugRenderer; - plugin: typeof spine + plugin: typeof spine; - getAtlasCanvas(key: string): spine.TextureAtlas - getAtlasWebGL(key: string): spine.TextureAtlas - worldToLocal(x: number, y: number, skeleton: spine.Skeleton, bone?: spine.Bone): spine.Vector2 - getVector2(x: number, y: number): spine.Vector2 - getVector3(x: number, y: number, z: number): spine.Vector2 - setDebugBones(value?: boolean): SpinePlugin - setDebugRegionAttachments(value?: boolean): SpinePlugin - setDebugBoundingBoxes(value?: boolean): SpinePlugin - setDebugMeshHull(value?: boolean): SpinePlugin - setDebugMeshTriangles(value?: boolean): SpinePlugin - setDebugPaths(value?: boolean): SpinePlugin - setDebugSkeletonXY(value?: boolean): SpinePlugin - setDebugClipping(value?: boolean): SpinePlugin - setEffect(effect?: spine.VertexEffect): SpinePlugin - createSkeleton(key: string, skeletonJSON?: object): any | null - createAnimationState(skeleton: spine.Skeleton): any - getBounds(skeleton: spine.Skeleton): any - onResize(): void - add(x: number, y: number, key?: string, animationName?: string, loop?: boolean): SpineGameObject - make(config: SpineGameObjectConfig, addToScene?: boolean): SpineGameObject + getAtlasCanvas(key: string): spine.TextureAtlas; + getAtlasWebGL(key: string): spine.TextureAtlas; + worldToLocal(x: number, y: number, skeleton: spine.Skeleton, bone?: spine.Bone): spine.Vector2; + getVector2(x: number, y: number): spine.Vector2; + getVector3(x: number, y: number, z: number): spine.Vector2; + setDebugBones(value?: boolean): SpinePlugin; + setDebugRegionAttachments(value?: boolean): SpinePlugin; + setDebugBoundingBoxes(value?: boolean): SpinePlugin; + setDebugMeshHull(value?: boolean): SpinePlugin; + setDebugMeshTriangles(value?: boolean): SpinePlugin; + setDebugPaths(value?: boolean): SpinePlugin; + setDebugSkeletonXY(value?: boolean): SpinePlugin; + setDebugClipping(value?: boolean): SpinePlugin; + setEffect(effect?: spine.VertexEffect): SpinePlugin; + createSkeleton(key: string, skeletonJSON?: object): any | null; + createAnimationState(skeleton: spine.Skeleton): any; + getBounds(skeleton: spine.Skeleton): any; + onResize(): void; + add(x: number, y: number, key?: string, animationName?: string, loop?: boolean): SpineGameObject; + make(config: SpineGameObjectConfig, addToScene?: boolean): SpineGameObject; } From bc39e704120cf1428d94a2691d9e7fac97195307 Mon Sep 17 00:00:00 2001 From: samme Date: Mon, 27 Jan 2020 11:15:06 -0800 Subject: [PATCH 02/23] Fix centering Body in setSize() --- src/physics/arcade/Body.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/physics/arcade/Body.js b/src/physics/arcade/Body.js index 5291dfcc2..1b6b14d1c 100644 --- a/src/physics/arcade/Body.js +++ b/src/physics/arcade/Body.js @@ -1233,10 +1233,10 @@ var Body = new Class({ if (center && gameObject.getCenter) { - var ox = gameObject.displayWidth / 2; - var oy = gameObject.displayHeight / 2; + var ox = (gameObject.width - width) / 2; + var oy = (gameObject.height - height) / 2; - this.offset.set(ox - this.halfWidth, oy - this.halfHeight); + this.offset.set(ox, oy); } this.isCircle = false; From 34176becb592b37a5e9e22e7170edf943c518470 Mon Sep 17 00:00:00 2001 From: samme Date: Sat, 1 Feb 2020 16:18:52 -0800 Subject: [PATCH 03/23] Correct `position` in constructor --- src/physics/arcade/Body.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/physics/arcade/Body.js b/src/physics/arcade/Body.js index 5291dfcc2..939c7840b 100644 --- a/src/physics/arcade/Body.js +++ b/src/physics/arcade/Body.js @@ -148,7 +148,10 @@ var Body = new Class({ * @type {Phaser.Math.Vector2} * @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. From 37c64dc0a9be6bcf9e8791cd00a0df57de770e85 Mon Sep 17 00:00:00 2001 From: samme Date: Sat, 1 Feb 2020 16:19:10 -0800 Subject: [PATCH 04/23] Correct `center` in constructor --- src/physics/arcade/Body.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/physics/arcade/Body.js b/src/physics/arcade/Body.js index 939c7840b..c05e43f0b 100644 --- a/src/physics/arcade/Body.js +++ b/src/physics/arcade/Body.js @@ -281,7 +281,7 @@ var Body = new Class({ * @type {Phaser.Math.Vector2} * @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. From a13d6237430b3c65a943a530cfe62ffd63b4108e Mon Sep 17 00:00:00 2001 From: samme Date: Sat, 1 Feb 2020 16:20:46 -0800 Subject: [PATCH 05/23] Correct dimensions from game object --- src/physics/arcade/StaticBody.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/physics/arcade/StaticBody.js b/src/physics/arcade/StaticBody.js index dab4ef63b..be6c4055e 100644 --- a/src/physics/arcade/StaticBody.js +++ b/src/physics/arcade/StaticBody.js @@ -35,8 +35,8 @@ var StaticBody = new Class({ function StaticBody (world, gameObject) { - var width = (gameObject.width) ? gameObject.width : 64; - var height = (gameObject.height) ? gameObject.height : 64; + var width = (gameObject.displayWidth) ? gameObject.displayWidth : 64; + var height = (gameObject.displayHeight) ? gameObject.displayHeight : 64; /** * The Arcade Physics simulation this Static Body belongs to. From c07c57f9f8713daa0f19f125b0312f44a763ed8e Mon Sep 17 00:00:00 2001 From: samme Date: Sat, 1 Feb 2020 16:27:02 -0800 Subject: [PATCH 06/23] Correct `center` --- src/physics/arcade/StaticBody.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/physics/arcade/StaticBody.js b/src/physics/arcade/StaticBody.js index be6c4055e..cb38d31d2 100644 --- a/src/physics/arcade/StaticBody.js +++ b/src/physics/arcade/StaticBody.js @@ -173,7 +173,7 @@ var StaticBody = new Class({ * @type {Phaser.Math.Vector2} * @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. From a312d038439cc3c24ced1a56802e33a39d46a82c Mon Sep 17 00:00:00 2001 From: samme Date: Sat, 1 Feb 2020 16:30:25 -0800 Subject: [PATCH 07/23] Docs for Phaser.Physics.Arcade.StaticBody `offset` is read only --- src/physics/arcade/StaticBody.js | 34 +++++++++++++++++--------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/physics/arcade/StaticBody.js b/src/physics/arcade/StaticBody.js index cb38d31d2..c88108b97 100644 --- a/src/physics/arcade/StaticBody.js +++ b/src/physics/arcade/StaticBody.js @@ -15,7 +15,7 @@ var Vector2 = require('../../math/Vector2'); * A Static Arcade Physics Body. * * 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. * @@ -95,8 +95,8 @@ var StaticBody = new Class({ 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. - * The true radius is equal to `halfWidth`. + * If this Static Body is circular, this is the radius of the boundary, as set by {@link Phaser.Physics.Arcade.StaticBody#setCircle}, in pixels. + * Equal to `halfWidth`. * * @name Phaser.Physics.Arcade.StaticBody#radius * @type {number} @@ -106,12 +106,13 @@ var StaticBody = new Class({ 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 * @type {Phaser.Math.Vector2} + * @readonly * @since 3.0.0 */ this.offset = new Vector2(); @@ -389,7 +390,7 @@ var StaticBody = new Class({ 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. * * @name Phaser.Physics.Arcade.StaticBody#_dx @@ -401,7 +402,7 @@ var StaticBody = new Class({ 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. * * @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 * @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 * @since 3.4.0 * - * @param {number} x - The horizontal offset of the Body from the Game Object's center. - * @param {number} y - The vertical 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 Static Body from the Game Object's `y`. * * @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. * * @method Phaser.Physics.Arcade.StaticBody#setSize * @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} [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 {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 {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 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] - 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. */ @@ -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 * @since 3.0.0 From 7d5673a0c7f313edcc588dd48fccd8380f2455a9 Mon Sep 17 00:00:00 2001 From: samme Date: Sat, 1 Feb 2020 17:25:15 -0800 Subject: [PATCH 08/23] Fix wrong body dimensions from a scaled game object --- src/physics/arcade/Body.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/physics/arcade/Body.js b/src/physics/arcade/Body.js index c05e43f0b..91fc51a4d 100644 --- a/src/physics/arcade/Body.js +++ b/src/physics/arcade/Body.js @@ -33,8 +33,8 @@ var Body = new Class({ function Body (world, gameObject) { - var width = (gameObject.width) ? gameObject.width : 64; - var height = (gameObject.height) ? gameObject.height : 64; + var width = (gameObject.displayWidth) ? gameObject.displayWidth : 64; + var height = (gameObject.displayHeight) ? gameObject.displayHeight : 64; /** * The Arcade Physics simulation this Body belongs to. From 6e244d51204d74f0289d67249859e5046225f183 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Tue, 4 Feb 2020 12:05:24 +0000 Subject: [PATCH 09/23] Update CHANGELOG.md --- CHANGELOG.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77778b287..9f4ea1225 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,12 +19,27 @@ ### Bug Fixes * 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 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 + +### Deprecated + +The following features have been deprecated and will be removed in _the next_ version: + +* Impact Physics will be removed completely and will no longer be a choice of physics system. +* 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. + + + ## Version 3.22 - Kohaku - January 15th 2020 From b5d91f1fdf03411cec265b447a534cd951819f5d Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Tue, 4 Feb 2020 14:51:43 +0000 Subject: [PATCH 10/23] Finished JSDocs --- src/math/Bernstein.js | 8 ++++---- src/math/CatmullRom.js | 12 ++++++------ src/math/Matrix3.js | 4 ++-- src/math/Matrix4.js | 10 +++++----- src/math/Quaternion.js | 6 +++--- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/math/Bernstein.js b/src/math/Bernstein.js index 8cbf7d874..6ba3f5a0c 100644 --- a/src/math/Bernstein.js +++ b/src/math/Bernstein.js @@ -7,15 +7,15 @@ var Factorial = require('./Factorial'); /** - * [description] + * Calculates the Bernstein basis from the three factorial coefficients. * * @function Phaser.Math.Bernstein * @since 3.0.0 * - * @param {number} n - [description] - * @param {number} i - [description] + * @param {number} n - The first value. + * @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) { diff --git a/src/math/CatmullRom.js b/src/math/CatmullRom.js index 23e850e61..b801833a9 100644 --- a/src/math/CatmullRom.js +++ b/src/math/CatmullRom.js @@ -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 * @since 3.0.0 * - * @param {number} t - [description] - * @param {number} p0 - [description] - * @param {number} p1 - [description] - * @param {number} p2 - [description] - * @param {number} p3 - [description] + * @param {number} t - The amount to interpolate by. + * @param {number} p0 - The first control point. + * @param {number} p1 - The second control point. + * @param {number} p2 - The third control point. + * @param {number} p3 - The fourth control point. * * @return {number} The Catmull-Rom value. */ diff --git a/src/math/Matrix3.js b/src/math/Matrix3.js index 2ef79d9bf..4a3f59fd1 100644 --- a/src/math/Matrix3.js +++ b/src/math/Matrix3.js @@ -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 * @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. */ diff --git a/src/math/Matrix4.js b/src/math/Matrix4.js index 066e83403..79494eb49 100644 --- a/src/math/Matrix4.js +++ b/src/math/Matrix4.js @@ -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 * @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. */ @@ -1356,9 +1356,9 @@ var Matrix4 = new Class({ * @method Phaser.Math.Matrix4#yawPitchRoll * @since 3.0.0 * - * @param {number} yaw - [description] - * @param {number} pitch - [description] - * @param {number} roll - [description] + * @param {number} yaw - The yaw value. + * @param {number} pitch - The pitch value. + * @param {number} roll - The roll value. * * @return {Phaser.Math.Matrix4} This Matrix4. */ diff --git a/src/math/Quaternion.js b/src/math/Quaternion.js index 6da0fa259..c1d33199e 100644 --- a/src/math/Quaternion.js +++ b/src/math/Quaternion.js @@ -317,13 +317,13 @@ var Quaternion = new Class({ }, /** - * [description] + * Rotates this Quaternion based on the two given vectors. * * @method Phaser.Math.Quaternion#rotationTo * @since 3.0.0 * - * @param {Phaser.Math.Vector3} a - [description] - * @param {Phaser.Math.Vector3} b - [description] + * @param {Phaser.Math.Vector3} a - The transform rotation vector. + * @param {Phaser.Math.Vector3} b - The target rotation vector. * * @return {Phaser.Math.Quaternion} This Quaternion. */ From 20fabba0b91f0fef46190234e86ed88bb4927382 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Tue, 4 Feb 2020 14:52:04 +0000 Subject: [PATCH 11/23] Impact Physics is now removed from the core API --- {src/physics => plugins}/impact/Body.js | 0 {src/physics => plugins}/impact/COLLIDES.js | 0 {src/physics => plugins}/impact/CollisionMap.js | 0 {src/physics => plugins}/impact/DefaultDefs.js | 0 {src/physics => plugins}/impact/Factory.js | 0 {src/physics => plugins}/impact/GetVelocity.js | 0 {src/physics => plugins}/impact/ImpactBody.js | 0 {src/physics => plugins}/impact/ImpactImage.js | 0 {src/physics => plugins}/impact/ImpactPhysics.js | 0 {src/physics => plugins}/impact/ImpactSprite.js | 0 {src/physics => plugins}/impact/SeparateX.js | 0 {src/physics => plugins}/impact/SeparateY.js | 0 {src/physics => plugins}/impact/Solver.js | 0 {src/physics => plugins}/impact/TYPE.js | 0 {src/physics => plugins}/impact/UpdateMotion.js | 0 {src/physics => plugins}/impact/World.js | 0 .../impact/components/Acceleration.js | 0 .../physics => plugins}/impact/components/BodyScale.js | 0 {src/physics => plugins}/impact/components/BodyType.js | 0 {src/physics => plugins}/impact/components/Bounce.js | 0 .../impact/components/CheckAgainst.js | 0 {src/physics => plugins}/impact/components/Collides.js | 0 {src/physics => plugins}/impact/components/Debug.js | 0 {src/physics => plugins}/impact/components/Friction.js | 0 {src/physics => plugins}/impact/components/Gravity.js | 0 {src/physics => plugins}/impact/components/Offset.js | 0 .../impact/components/SetGameObject.js | 0 {src/physics => plugins}/impact/components/Velocity.js | 0 {src/physics => plugins}/impact/components/index.js | 0 .../physics => plugins}/impact/events/COLLIDE_EVENT.js | 0 {src/physics => plugins}/impact/events/PAUSE_EVENT.js | 0 {src/physics => plugins}/impact/events/RESUME_EVENT.js | 0 {src/physics => plugins}/impact/events/index.js | 0 {src/physics => plugins}/impact/index.js | 0 .../impact/typedefs/CollisionOptions.js | 0 .../impact/typedefs/JSONImpactBody.js | 0 .../physics => plugins}/impact/typedefs/WorldConfig.js | 0 .../impact/typedefs/WorldDefaults.js | 0 {src/physics => plugins}/impact/typedefs/WorldWalls.js | 0 {src/physics => plugins}/impact/typedefs/index.js | 0 src/core/typedefs/PhysicsConfig.js | 3 +-- src/gameobjects/GameObject.js | 4 ++-- src/physics/index.js | 1 - src/scene/Scene.js | 10 ---------- 44 files changed, 3 insertions(+), 15 deletions(-) rename {src/physics => plugins}/impact/Body.js (100%) rename {src/physics => plugins}/impact/COLLIDES.js (100%) rename {src/physics => plugins}/impact/CollisionMap.js (100%) rename {src/physics => plugins}/impact/DefaultDefs.js (100%) rename {src/physics => plugins}/impact/Factory.js (100%) rename {src/physics => plugins}/impact/GetVelocity.js (100%) rename {src/physics => plugins}/impact/ImpactBody.js (100%) rename {src/physics => plugins}/impact/ImpactImage.js (100%) rename {src/physics => plugins}/impact/ImpactPhysics.js (100%) rename {src/physics => plugins}/impact/ImpactSprite.js (100%) rename {src/physics => plugins}/impact/SeparateX.js (100%) rename {src/physics => plugins}/impact/SeparateY.js (100%) rename {src/physics => plugins}/impact/Solver.js (100%) rename {src/physics => plugins}/impact/TYPE.js (100%) rename {src/physics => plugins}/impact/UpdateMotion.js (100%) rename {src/physics => plugins}/impact/World.js (100%) rename {src/physics => plugins}/impact/components/Acceleration.js (100%) rename {src/physics => plugins}/impact/components/BodyScale.js (100%) rename {src/physics => plugins}/impact/components/BodyType.js (100%) rename {src/physics => plugins}/impact/components/Bounce.js (100%) rename {src/physics => plugins}/impact/components/CheckAgainst.js (100%) rename {src/physics => plugins}/impact/components/Collides.js (100%) rename {src/physics => plugins}/impact/components/Debug.js (100%) rename {src/physics => plugins}/impact/components/Friction.js (100%) rename {src/physics => plugins}/impact/components/Gravity.js (100%) rename {src/physics => plugins}/impact/components/Offset.js (100%) rename {src/physics => plugins}/impact/components/SetGameObject.js (100%) rename {src/physics => plugins}/impact/components/Velocity.js (100%) rename {src/physics => plugins}/impact/components/index.js (100%) rename {src/physics => plugins}/impact/events/COLLIDE_EVENT.js (100%) rename {src/physics => plugins}/impact/events/PAUSE_EVENT.js (100%) rename {src/physics => plugins}/impact/events/RESUME_EVENT.js (100%) rename {src/physics => plugins}/impact/events/index.js (100%) rename {src/physics => plugins}/impact/index.js (100%) rename {src/physics => plugins}/impact/typedefs/CollisionOptions.js (100%) rename {src/physics => plugins}/impact/typedefs/JSONImpactBody.js (100%) rename {src/physics => plugins}/impact/typedefs/WorldConfig.js (100%) rename {src/physics => plugins}/impact/typedefs/WorldDefaults.js (100%) rename {src/physics => plugins}/impact/typedefs/WorldWalls.js (100%) rename {src/physics => plugins}/impact/typedefs/index.js (100%) diff --git a/src/physics/impact/Body.js b/plugins/impact/Body.js similarity index 100% rename from src/physics/impact/Body.js rename to plugins/impact/Body.js diff --git a/src/physics/impact/COLLIDES.js b/plugins/impact/COLLIDES.js similarity index 100% rename from src/physics/impact/COLLIDES.js rename to plugins/impact/COLLIDES.js diff --git a/src/physics/impact/CollisionMap.js b/plugins/impact/CollisionMap.js similarity index 100% rename from src/physics/impact/CollisionMap.js rename to plugins/impact/CollisionMap.js diff --git a/src/physics/impact/DefaultDefs.js b/plugins/impact/DefaultDefs.js similarity index 100% rename from src/physics/impact/DefaultDefs.js rename to plugins/impact/DefaultDefs.js diff --git a/src/physics/impact/Factory.js b/plugins/impact/Factory.js similarity index 100% rename from src/physics/impact/Factory.js rename to plugins/impact/Factory.js diff --git a/src/physics/impact/GetVelocity.js b/plugins/impact/GetVelocity.js similarity index 100% rename from src/physics/impact/GetVelocity.js rename to plugins/impact/GetVelocity.js diff --git a/src/physics/impact/ImpactBody.js b/plugins/impact/ImpactBody.js similarity index 100% rename from src/physics/impact/ImpactBody.js rename to plugins/impact/ImpactBody.js diff --git a/src/physics/impact/ImpactImage.js b/plugins/impact/ImpactImage.js similarity index 100% rename from src/physics/impact/ImpactImage.js rename to plugins/impact/ImpactImage.js diff --git a/src/physics/impact/ImpactPhysics.js b/plugins/impact/ImpactPhysics.js similarity index 100% rename from src/physics/impact/ImpactPhysics.js rename to plugins/impact/ImpactPhysics.js diff --git a/src/physics/impact/ImpactSprite.js b/plugins/impact/ImpactSprite.js similarity index 100% rename from src/physics/impact/ImpactSprite.js rename to plugins/impact/ImpactSprite.js diff --git a/src/physics/impact/SeparateX.js b/plugins/impact/SeparateX.js similarity index 100% rename from src/physics/impact/SeparateX.js rename to plugins/impact/SeparateX.js diff --git a/src/physics/impact/SeparateY.js b/plugins/impact/SeparateY.js similarity index 100% rename from src/physics/impact/SeparateY.js rename to plugins/impact/SeparateY.js diff --git a/src/physics/impact/Solver.js b/plugins/impact/Solver.js similarity index 100% rename from src/physics/impact/Solver.js rename to plugins/impact/Solver.js diff --git a/src/physics/impact/TYPE.js b/plugins/impact/TYPE.js similarity index 100% rename from src/physics/impact/TYPE.js rename to plugins/impact/TYPE.js diff --git a/src/physics/impact/UpdateMotion.js b/plugins/impact/UpdateMotion.js similarity index 100% rename from src/physics/impact/UpdateMotion.js rename to plugins/impact/UpdateMotion.js diff --git a/src/physics/impact/World.js b/plugins/impact/World.js similarity index 100% rename from src/physics/impact/World.js rename to plugins/impact/World.js diff --git a/src/physics/impact/components/Acceleration.js b/plugins/impact/components/Acceleration.js similarity index 100% rename from src/physics/impact/components/Acceleration.js rename to plugins/impact/components/Acceleration.js diff --git a/src/physics/impact/components/BodyScale.js b/plugins/impact/components/BodyScale.js similarity index 100% rename from src/physics/impact/components/BodyScale.js rename to plugins/impact/components/BodyScale.js diff --git a/src/physics/impact/components/BodyType.js b/plugins/impact/components/BodyType.js similarity index 100% rename from src/physics/impact/components/BodyType.js rename to plugins/impact/components/BodyType.js diff --git a/src/physics/impact/components/Bounce.js b/plugins/impact/components/Bounce.js similarity index 100% rename from src/physics/impact/components/Bounce.js rename to plugins/impact/components/Bounce.js diff --git a/src/physics/impact/components/CheckAgainst.js b/plugins/impact/components/CheckAgainst.js similarity index 100% rename from src/physics/impact/components/CheckAgainst.js rename to plugins/impact/components/CheckAgainst.js diff --git a/src/physics/impact/components/Collides.js b/plugins/impact/components/Collides.js similarity index 100% rename from src/physics/impact/components/Collides.js rename to plugins/impact/components/Collides.js diff --git a/src/physics/impact/components/Debug.js b/plugins/impact/components/Debug.js similarity index 100% rename from src/physics/impact/components/Debug.js rename to plugins/impact/components/Debug.js diff --git a/src/physics/impact/components/Friction.js b/plugins/impact/components/Friction.js similarity index 100% rename from src/physics/impact/components/Friction.js rename to plugins/impact/components/Friction.js diff --git a/src/physics/impact/components/Gravity.js b/plugins/impact/components/Gravity.js similarity index 100% rename from src/physics/impact/components/Gravity.js rename to plugins/impact/components/Gravity.js diff --git a/src/physics/impact/components/Offset.js b/plugins/impact/components/Offset.js similarity index 100% rename from src/physics/impact/components/Offset.js rename to plugins/impact/components/Offset.js diff --git a/src/physics/impact/components/SetGameObject.js b/plugins/impact/components/SetGameObject.js similarity index 100% rename from src/physics/impact/components/SetGameObject.js rename to plugins/impact/components/SetGameObject.js diff --git a/src/physics/impact/components/Velocity.js b/plugins/impact/components/Velocity.js similarity index 100% rename from src/physics/impact/components/Velocity.js rename to plugins/impact/components/Velocity.js diff --git a/src/physics/impact/components/index.js b/plugins/impact/components/index.js similarity index 100% rename from src/physics/impact/components/index.js rename to plugins/impact/components/index.js diff --git a/src/physics/impact/events/COLLIDE_EVENT.js b/plugins/impact/events/COLLIDE_EVENT.js similarity index 100% rename from src/physics/impact/events/COLLIDE_EVENT.js rename to plugins/impact/events/COLLIDE_EVENT.js diff --git a/src/physics/impact/events/PAUSE_EVENT.js b/plugins/impact/events/PAUSE_EVENT.js similarity index 100% rename from src/physics/impact/events/PAUSE_EVENT.js rename to plugins/impact/events/PAUSE_EVENT.js diff --git a/src/physics/impact/events/RESUME_EVENT.js b/plugins/impact/events/RESUME_EVENT.js similarity index 100% rename from src/physics/impact/events/RESUME_EVENT.js rename to plugins/impact/events/RESUME_EVENT.js diff --git a/src/physics/impact/events/index.js b/plugins/impact/events/index.js similarity index 100% rename from src/physics/impact/events/index.js rename to plugins/impact/events/index.js diff --git a/src/physics/impact/index.js b/plugins/impact/index.js similarity index 100% rename from src/physics/impact/index.js rename to plugins/impact/index.js diff --git a/src/physics/impact/typedefs/CollisionOptions.js b/plugins/impact/typedefs/CollisionOptions.js similarity index 100% rename from src/physics/impact/typedefs/CollisionOptions.js rename to plugins/impact/typedefs/CollisionOptions.js diff --git a/src/physics/impact/typedefs/JSONImpactBody.js b/plugins/impact/typedefs/JSONImpactBody.js similarity index 100% rename from src/physics/impact/typedefs/JSONImpactBody.js rename to plugins/impact/typedefs/JSONImpactBody.js diff --git a/src/physics/impact/typedefs/WorldConfig.js b/plugins/impact/typedefs/WorldConfig.js similarity index 100% rename from src/physics/impact/typedefs/WorldConfig.js rename to plugins/impact/typedefs/WorldConfig.js diff --git a/src/physics/impact/typedefs/WorldDefaults.js b/plugins/impact/typedefs/WorldDefaults.js similarity index 100% rename from src/physics/impact/typedefs/WorldDefaults.js rename to plugins/impact/typedefs/WorldDefaults.js diff --git a/src/physics/impact/typedefs/WorldWalls.js b/plugins/impact/typedefs/WorldWalls.js similarity index 100% rename from src/physics/impact/typedefs/WorldWalls.js rename to plugins/impact/typedefs/WorldWalls.js diff --git a/src/physics/impact/typedefs/index.js b/plugins/impact/typedefs/index.js similarity index 100% rename from src/physics/impact/typedefs/index.js rename to plugins/impact/typedefs/index.js diff --git a/src/core/typedefs/PhysicsConfig.js b/src/core/typedefs/PhysicsConfig.js index 838f72ea0..6f0c785a8 100644 --- a/src/core/typedefs/PhysicsConfig.js +++ b/src/core/typedefs/PhysicsConfig.js @@ -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 {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. */ diff --git a/src/gameobjects/GameObject.js b/src/gameobjects/GameObject.js index c21b49d60..99c8094bc 100644 --- a/src/gameobjects/GameObject.js +++ b/src/gameobjects/GameObject.js @@ -166,10 +166,10 @@ var GameObject = new Class({ 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 Physics then this property will contain a reference to a Physics Body. * * @name Phaser.GameObjects.GameObject#body - * @type {?(object|Phaser.Physics.Arcade.Body|Phaser.Physics.Impact.Body)} + * @type {?(object|Phaser.Physics.Arcade.Body)} * @default null * @since 3.0.0 */ diff --git a/src/physics/index.js b/src/physics/index.js index 5d17cac35..cd52da3b0 100644 --- a/src/physics/index.js +++ b/src/physics/index.js @@ -15,7 +15,6 @@ module.exports = { Arcade: require('./arcade'), - Impact: require('./impact'), Matter: require('./matter-js') }; diff --git a/src/scene/Scene.js b/src/scene/Scene.js index 5c1bfdfed..6818d3956 100644 --- a/src/scene/Scene.js +++ b/src/scene/Scene.js @@ -225,16 +225,6 @@ var Scene = new Class({ */ 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. * This property will only be available if defined in the Scene Injection Map, the plugin is installed and configured. From bbde2570d437aed667382f07486b601f6bc1a977 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Tue, 4 Feb 2020 14:52:06 +0000 Subject: [PATCH 12/23] Update CHANGELOG.md --- CHANGELOG.md | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f4ea1225..8453e70d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,25 @@ ## Version 3.23 - Ginro - in development +### JSDocs + +The following sections now have 100% complete JSDoc coverage: + +* Math + +### 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 * `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. @@ -31,16 +50,6 @@ My thanks to the following for helping with the Phaser 3 Examples, Docs and Type @JasonHK @supertommy -### Deprecated - -The following features have been deprecated and will be removed in _the next_ version: - -* Impact Physics will be removed completely and will no longer be a choice of physics system. -* 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. - - - - ## Version 3.22 - Kohaku - January 15th 2020 ### Matter Physics From 8f52fe59bb69681d288480a8620f6a08047ab0d8 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Tue, 4 Feb 2020 14:56:28 +0000 Subject: [PATCH 13/23] Completed JSDocs --- src/textures/TextureManager.js | 4 ++-- src/textures/parsers/SpriteSheet.js | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/textures/TextureManager.js b/src/textures/TextureManager.js index 7372bfcaa..69cbc8ff6 100644 --- a/src/textures/TextureManager.js +++ b/src/textures/TextureManager.js @@ -299,8 +299,8 @@ var TextureManager = new Class({ * * @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} [type='image/png'] - [description] - * @param {number} [encoderOptions=0.92] - [description] + * @param {string} [type='image/png'] - A DOMString indicating the image format. The default format type is image/png. + * @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. */ diff --git a/src/textures/parsers/SpriteSheet.js b/src/textures/parsers/SpriteSheet.js index 23bffc2ca..d0d7e8b57 100644 --- a/src/textures/parsers/SpriteSheet.js +++ b/src/textures/parsers/SpriteSheet.js @@ -19,15 +19,15 @@ var GetFastValue = require('../../utils/object/GetFastValue'); * * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. * @param {integer} sourceIndex - The index of the TextureSource. - * @param {integer} x - [description] - * @param {integer} y - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] + * @param {integer} x - The top-left coordinate of the Sprite Sheet. Defaults to zero. Used when extracting sheets from atlases. + * @param {integer} y - The top-left coordinate of the Sprite Sheet. Defaults to zero. Used when extracting sheets from atlases. + * @param {integer} width - The width of the source image. + * @param {integer} height - The height of the source image. * @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.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.endFrame=-1] - [description] + * @param {number} [config.startFrame=0] - The frame to start extracting from. Defaults to zero. + * @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.spacing=0] - If the frames have been drawn with spacing between them, specify the amount here. * From 11a24cdb73474fede57346cda81bed6415cbc54e Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Tue, 4 Feb 2020 14:56:32 +0000 Subject: [PATCH 14/23] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8453e70d8..5312b753c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ The following sections now have 100% complete JSDoc coverage: * Math +* Textures ### Removed From 0ee6d16c17e7cf1817840e287a5011c4f1017285 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Tue, 4 Feb 2020 16:19:42 +0000 Subject: [PATCH 15/23] Finished Geom JSDocs --- src/geom/line/NormalX.js | 4 ++-- src/geom/point/GetCentroid.js | 6 +++--- src/geom/point/GetRectangleFromPoints.js | 6 +++--- src/geom/point/Interpolate.js | 2 +- src/geom/point/Project.js | 11 ++++++----- src/geom/point/ProjectUnit.js | 11 ++++++----- src/geom/polygon/ContainsPoint.js | 8 ++++---- src/geom/rectangle/GetPoint.js | 14 +++++++++----- src/geom/rectangle/GetSize.js | 10 +++++----- src/geom/rectangle/MarchingAnts.js | 14 +++++++------- src/geom/rectangle/PerimeterPoint.js | 10 +++++----- src/geom/triangle/BuildFromPolygon.js | 11 ++++++----- src/geom/triangle/CircumCenter.js | 6 +++--- src/geom/triangle/Perimeter.js | 7 +++---- src/geom/triangle/Random.js | 8 ++++---- 15 files changed, 67 insertions(+), 61 deletions(-) diff --git a/src/geom/line/NormalX.js b/src/geom/line/NormalX.js index 8c3de902c..8cb0a3d84 100644 --- a/src/geom/line/NormalX.js +++ b/src/geom/line/NormalX.js @@ -8,14 +8,14 @@ var MATH_CONST = require('../../math/const'); var Angle = require('./Angle'); /** - * [description] + * Returns the x component of the normal vector of the given line. * * @function Phaser.Geom.Line.NormalX * @since 3.0.0 * * @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) { diff --git a/src/geom/point/GetCentroid.js b/src/geom/point/GetCentroid.js index db460048e..c081fe4f8 100644 --- a/src/geom/point/GetCentroid.js +++ b/src/geom/point/GetCentroid.js @@ -15,10 +15,10 @@ var Point = require('./Point'); * * @generic {Phaser.Geom.Point} O - [out,$return] * - * @param {Phaser.Geom.Point[]} points - [description] - * @param {Phaser.Geom.Point} [out] - [description] + * @param {Phaser.Types.Math.Vector2Like[]} points - An array of Vector2Like objects to get the geometric center of. + * @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) { diff --git a/src/geom/point/GetRectangleFromPoints.js b/src/geom/point/GetRectangleFromPoints.js index bea998048..3927bbadf 100644 --- a/src/geom/point/GetRectangleFromPoints.js +++ b/src/geom/point/GetRectangleFromPoints.js @@ -14,10 +14,10 @@ var Rectangle = require('../rectangle/Rectangle'); * * @generic {Phaser.Geom.Rectangle} O - [out,$return] * - * @param {Phaser.Geom.Point[]} points - [description] - * @param {Phaser.Geom.Rectangle} [out] - [description] + * @param {Phaser.Types.Math.Vector2Like[]} points - An array of Vector2Like objects to get the AABB from. + * @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) { diff --git a/src/geom/point/Interpolate.js b/src/geom/point/Interpolate.js index 2048868a8..fcd4e1a90 100644 --- a/src/geom/point/Interpolate.js +++ b/src/geom/point/Interpolate.js @@ -7,7 +7,7 @@ var Point = require('./Point'); /** - * [description] + * Returns the linear interpolation point between the two given points, based on `t`. * * @function Phaser.Geom.Point.Interpolate * @since 3.0.0 diff --git a/src/geom/point/Project.js b/src/geom/point/Project.js index 7446f2be9..219b80f6c 100644 --- a/src/geom/point/Project.js +++ b/src/geom/point/Project.js @@ -8,18 +8,19 @@ var Point = require('./Point'); 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 * @since 3.0.0 * * @generic {Phaser.Geom.Point} O - [out,$return] * - * @param {Phaser.Geom.Point} pointA - [description] - * @param {Phaser.Geom.Point} pointB - [description] - * @param {Phaser.Geom.Point} [out] - [description] + * @param {Phaser.Geom.Point} pointA - Point A, to be projected onto Point B. + * @param {Phaser.Geom.Point} pointB - Point B, to have Point A projected upon it. + * @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) { diff --git a/src/geom/point/ProjectUnit.js b/src/geom/point/ProjectUnit.js index e8a013820..236d2a2db 100644 --- a/src/geom/point/ProjectUnit.js +++ b/src/geom/point/ProjectUnit.js @@ -7,18 +7,19 @@ 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 * @since 3.0.0 * * @generic {Phaser.Geom.Point} O - [out,$return] * - * @param {Phaser.Geom.Point} pointA - [description] - * @param {Phaser.Geom.Point} pointB - [description] - * @param {Phaser.Geom.Point} [out] - [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 - Point B, to have Point A projected upon it. + * @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) { diff --git a/src/geom/polygon/ContainsPoint.js b/src/geom/polygon/ContainsPoint.js index ce23aa20c..09e52a7c2 100644 --- a/src/geom/polygon/ContainsPoint.js +++ b/src/geom/polygon/ContainsPoint.js @@ -7,15 +7,15 @@ 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 * @since 3.0.0 * - * @param {Phaser.Geom.Polygon} polygon - [description] - * @param {Phaser.Geom.Point} point - [description] + * @param {Phaser.Geom.Polygon} polygon - The Polygon to check. + * @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) { diff --git a/src/geom/rectangle/GetPoint.js b/src/geom/rectangle/GetPoint.js index af659fe52..3a4f4dfcf 100644 --- a/src/geom/rectangle/GetPoint.js +++ b/src/geom/rectangle/GetPoint.js @@ -8,18 +8,22 @@ var Perimeter = require('./Perimeter'); 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 * @since 3.0.0 * * @generic {Phaser.Geom.Point} O - [out,$return] * - * @param {Phaser.Geom.Rectangle} rectangle - [description] - * @param {number} position - [description] - * @param {(Phaser.Geom.Point|object)} [out] - [description] + * @param {Phaser.Geom.Rectangle} rectangle - The Rectangle to get the perimeter point from. + * @param {number} position - The normalized distance into the Rectangle's perimeter to return. + * @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) { diff --git a/src/geom/rectangle/GetSize.js b/src/geom/rectangle/GetSize.js index bdfaa6cc4..d8f8f5fd7 100644 --- a/src/geom/rectangle/GetSize.js +++ b/src/geom/rectangle/GetSize.js @@ -8,18 +8,18 @@ var Point = require('../point/Point'); /** - * The size of the Rectangle object, expressed as a Point object - * with the values of the width and height properties. + * Returns the size of the Rectangle, expressed as a Point object. + * With the value of the `width` as the `x` property and the `height` as the `y` property. * * @function Phaser.Geom.Rectangle.GetSize * @since 3.0.0 * * @generic {Phaser.Geom.Point} O - [out,$return] * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {(Phaser.Geom.Point|object)} [out] - [description] + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to get the size from. + * @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) { diff --git a/src/geom/rectangle/MarchingAnts.js b/src/geom/rectangle/MarchingAnts.js index bac6f1f97..c0c452cea 100644 --- a/src/geom/rectangle/MarchingAnts.js +++ b/src/geom/rectangle/MarchingAnts.js @@ -9,20 +9,20 @@ var Point = require('../point/Point'); /** - * Return an array of points from the perimeter of the rectangle - * each spaced out based on the quantity or step required + * Returns an array of points from the perimeter of the Rectangle, where each point is spaced out based + * on either the `step` value, or the `quantity`. * * @function Phaser.Geom.Rectangle.MarchingAnts * @since 3.0.0 * * @generic {Phaser.Geom.Point[]} O - [out,$return] * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} step - [description] - * @param {integer} quantity - [description] - * @param {(array|Phaser.Geom.Point[])} [out] - [description] + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to get the perimeter points from. + * @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] - 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] - 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) { diff --git a/src/geom/rectangle/PerimeterPoint.js b/src/geom/rectangle/PerimeterPoint.js index 48c913bfc..e76b79702 100644 --- a/src/geom/rectangle/PerimeterPoint.js +++ b/src/geom/rectangle/PerimeterPoint.js @@ -8,18 +8,18 @@ var Point = require('../point/Point'); 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 * @since 3.0.0 * * @generic {Phaser.Geom.Point} O - [out,$return] * - * @param {Phaser.Geom.Rectangle} rectangle - [description] - * @param {integer} angle - [description] - * @param {Phaser.Geom.Point} [out] - [description] + * @param {Phaser.Geom.Rectangle} rectangle - The Rectangle to get the perimeter point from. + * @param {integer} angle - The angle of the point, in degrees. + * @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) { diff --git a/src/geom/triangle/BuildFromPolygon.js b/src/geom/triangle/BuildFromPolygon.js index e0c46e09f..f8a1096fc 100644 --- a/src/geom/triangle/BuildFromPolygon.js +++ b/src/geom/triangle/BuildFromPolygon.js @@ -8,7 +8,8 @@ var EarCut = require('../polygon/Earcut'); 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 * @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} [holes=null] - An array of hole indices if any (e.g. [5, 8] for a 12-vertex input would mean one hole with vertices 5–7 and another with 8–11). - * @param {number} [scaleX=1] - [description] - * @param {number} [scaleY=1] - [description] - * @param {(array|Phaser.Geom.Triangle[])} [out] - [description] + * @param {number} [scaleX=1] - Horizontal scale factor to multiply the resulting points by. + * @param {number} [scaleY=1] - Vertical scale factor to multiply the resulting points by. + * @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) { diff --git a/src/geom/triangle/CircumCenter.js b/src/geom/triangle/CircumCenter.js index cad696ed0..a8bae4ffa 100644 --- a/src/geom/triangle/CircumCenter.js +++ b/src/geom/triangle/CircumCenter.js @@ -39,10 +39,10 @@ function det (m00, m01, m10, m11) * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Math.Vector2} [out] - [description] + * @param {Phaser.Geom.Triangle} triangle - The Triangle to get the circumcenter of. + * @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) { diff --git a/src/geom/triangle/Perimeter.js b/src/geom/triangle/Perimeter.js index 6bf7e62b3..65cb3b32e 100644 --- a/src/geom/triangle/Perimeter.js +++ b/src/geom/triangle/Perimeter.js @@ -6,17 +6,16 @@ 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. + * Calculated by adding together the length of each of the three sides. * * @function Phaser.Geom.Triangle.Perimeter * @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) { diff --git a/src/geom/triangle/Random.js b/src/geom/triangle/Random.js index 9796e9175..92687c15c 100644 --- a/src/geom/triangle/Random.js +++ b/src/geom/triangle/Random.js @@ -7,17 +7,17 @@ var Point = require('../point/Point'); /** - * [description] + * Returns a random Point from within the area of the given Triangle. * * @function Phaser.Geom.Triangle.Random * @since 3.0.0 * * @generic {Phaser.Geom.Point} O - [out,$return] * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Point} [out] - [description] + * @param {Phaser.Geom.Triangle} triangle - The Triangle to get a random point from. + * @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) { From d58211da71de696386687596b4ca704ed92c69b4 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Tue, 4 Feb 2020 16:19:46 +0000 Subject: [PATCH 16/23] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5312b753c..192bf7ba2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The following sections now have 100% complete JSDoc coverage: * Math * Textures +* Geom ### Removed From e675c21db1f3b92c4d8afa7755e5873a9d69799a Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Tue, 4 Feb 2020 16:53:33 +0000 Subject: [PATCH 17/23] Finished JSDocs --- src/animations/Animation.js | 59 ++++++++++++---------- src/animations/AnimationManager.js | 61 +++++++++++++++++------ src/animations/typedefs/AnimationFrame.js | 6 +-- src/animations/typedefs/JSONAnimation.js | 2 +- 4 files changed, 84 insertions(+), 44 deletions(-) diff --git a/src/animations/Animation.js b/src/animations/Animation.js index 0502b7c0f..7c5c2f87b 100644 --- a/src/animations/Animation.js +++ b/src/animations/Animation.js @@ -224,7 +224,7 @@ var Animation = new Class({ * @method Phaser.Animations.Animation#addFrame * @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. */ @@ -240,7 +240,7 @@ var Animation = new Class({ * @since 3.0.0 * * @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. */ @@ -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 * @protected * @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) { @@ -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 * @protected * @since 3.0.0 * - * @param {Phaser.GameObjects.Components.Animation} component - [description] - * @param {boolean} [includeDelay=true] - [description] + * @param {Phaser.GameObjects.Components.Animation} component - The Animation Component belonging to the Game Object invoking this call. + * @param {boolean} [includeDelay=true] - If `true` the Animation Components delay value will be added to the `nextTick` total. */ 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 * @since 3.0.0 * - * @param {Phaser.Textures.TextureManager} textureManager - [description] - * @param {(string|Phaser.Types.Animations.AnimationFrame[])} frames - [description] - * @param {string} [defaultTextureKey] - [description] + * @param {Phaser.Textures.TextureManager} textureManager - A reference to the global Texture Manager. + * @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] - 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) { @@ -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 * @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) { @@ -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 * @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) { @@ -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 * @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. */ @@ -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 * @fires Phaser.Animations.Events#ANIMATION_REPEAT @@ -737,7 +742,7 @@ var Animation = new Class({ * @fires Phaser.Animations.Events#SPRITE_ANIMATION_KEY_REPEAT * @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) { @@ -782,7 +787,7 @@ var Animation = new Class({ * @method Phaser.Animations.Animation#setFrame * @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) { @@ -803,7 +808,7 @@ var Animation = new Class({ * @method Phaser.Animations.Animation#toJSON * @since 3.0.0 * - * @return {Phaser.Types.Animations.JSONAnimation} [description] + * @return {Phaser.Types.Animations.JSONAnimation} The resulting JSONAnimation formatted object. */ 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 * @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 * @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 * @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 * @since 3.0.0 diff --git a/src/animations/AnimationManager.js b/src/animations/AnimationManager.js index 9a56d3d42..9cc54353a 100644 --- a/src/animations/AnimationManager.js +++ b/src/animations/AnimationManager.js @@ -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 * @since 3.0.0 @@ -340,6 +367,8 @@ var AnimationManager = new Class({ * Generate an array of {@link Phaser.Types.Animations.AnimationFrame} objects from a texture key and configuration object. * * 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 * @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 * @fires Phaser.Animations.Events#REMOVE_ANIMATION @@ -513,7 +545,7 @@ var AnimationManager = new Class({ * * @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) { @@ -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 * @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) { + var output = { + anims: [], + globalTimeScale: this.globalTimeScale + }; + if (key !== undefined && key !== '') { - return this.anims.get(key).toJSON(); + output.anims.push(this.anims.get(key).toJSON()); } else { - var output = { - anims: [], - globalTimeScale: this.globalTimeScale - }; - this.anims.each(function (animationKey, animation) { output.anims.push(animation.toJSON()); }); - - return output; } + + return output; }, /** diff --git a/src/animations/typedefs/AnimationFrame.js b/src/animations/typedefs/AnimationFrame.js index 71c9109f4..8b0126106 100644 --- a/src/animations/typedefs/AnimationFrame.js +++ b/src/animations/typedefs/AnimationFrame.js @@ -3,7 +3,7 @@ * @since 3.0.0 * * @property {string} key - The key that the animation will be associated with. i.e. sprite.animations.play(key) - * @property {(string|number)} frame - [description] - * @property {number} [duration=0] - [description] - * @property {boolean} [visible] - [description] + * @property {(string|number)} frame - The key, or index number, of the frame within the animation. + * @property {number} [duration=0] - The duration, in ms, of this frame of the animation. + * @property {boolean} [visible] - Should the parent Game Object be visible during this frame of the animation? */ diff --git a/src/animations/typedefs/JSONAnimation.js b/src/animations/typedefs/JSONAnimation.js index 361f99576..9ae13c7a3 100644 --- a/src/animations/typedefs/JSONAnimation.js +++ b/src/animations/typedefs/JSONAnimation.js @@ -4,7 +4,7 @@ * * @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 {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} 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? From 25bdc565f247d299f1ac8bcbba9c88651fc7c86d Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Tue, 4 Feb 2020 16:53:36 +0000 Subject: [PATCH 18/23] Update CHANGELOG.md --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 192bf7ba2..ea6dc7ce9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,9 +6,10 @@ The following sections now have 100% complete JSDoc coverage: +* Animations +* Geom * Math * Textures -* Geom ### Removed From 3183f1e7de30a657d06405690f5b43161cfd8afd Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Tue, 4 Feb 2020 17:16:19 +0000 Subject: [PATCH 19/23] Finished JSDocs --- src/create/GenerateTexture.js | 34 ++++++++++++++++++-- src/create/typedefs/GenerateTextureConfig.js | 18 +++++------ src/textures/TextureManager.js | 34 ++++++++++++++++++-- 3 files changed, 72 insertions(+), 14 deletions(-) diff --git a/src/create/GenerateTexture.js b/src/create/GenerateTexture.js index 3176e89a8..87f682970 100644 --- a/src/create/GenerateTexture.js +++ b/src/create/GenerateTexture.js @@ -9,14 +9,42 @@ var CanvasPool = require('../display/canvas/CanvasPool'); 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 * @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) { diff --git a/src/create/typedefs/GenerateTextureConfig.js b/src/create/typedefs/GenerateTextureConfig.js index 3a83d8865..a001a9bae 100644 --- a/src/create/typedefs/GenerateTextureConfig.js +++ b/src/create/typedefs/GenerateTextureConfig.js @@ -2,21 +2,21 @@ * @callback Phaser.Types.Create.GenerateTextureCallback * @since 3.0.0 * - * @param {HTMLCanvasElement} canvas - [description] - * @param {CanvasRenderingContext2D} context - [description] + * @param {HTMLCanvasElement} canvas - The HTML Canvas element to operate on. + * @param {CanvasRenderingContext2D} context - The context of the HTML Canvas element. */ /** * @typedef {object} Phaser.Types.Create.GenerateTextureConfig * @since 3.0.0 * - * @property {array} [data=[]] - [description] - * @property {HTMLCanvasElement} [canvas=null] - [description] - * @property {Phaser.Types.Create.Palette} [palette=Arne16] - [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] - The HTML Canvas to draw the texture to. + * @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} [pixelHeight=1] - The height of each 'pixel' in the generated texture. - * @property {boolean} [resizeCanvas=true] - [description] - * @property {boolean} [clearCanvas=true] - [description] - * @property {Phaser.Types.Create.GenerateTextureCallback} [preRender] - [description] - * @property {Phaser.Types.Create.GenerateTextureCallback} [postRender] - [description] + * @property {boolean} [resizeCanvas=true] - Should the canvas be resized before the texture is drawn? + * @property {boolean} [clearCanvas=true] - Should the canvas be cleared before the texture is drawn? + * @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] - A callback to send the canvas to after the texture has been drawn. */ diff --git a/src/textures/TextureManager.js b/src/textures/TextureManager.js index 69cbc8ff6..da04abff5 100644 --- a/src/textures/TextureManager.js +++ b/src/textures/TextureManager.js @@ -443,14 +443,44 @@ var TextureManager = new Class({ /** * Creates a new Texture using the given config values. + * * 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 * @since 3.0.0 * * @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. */ From 03ee36f9ba2255f8c863c907a30c54265a20908a Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Tue, 4 Feb 2020 17:30:27 +0000 Subject: [PATCH 20/23] Finished JSDocs --- src/renderer/webgl/Utils.js | 2 +- src/renderer/webgl/WebGLRenderer.js | 110 +++++++++++------- .../webgl/pipelines/BitmapMaskPipeline.js | 12 +- 3 files changed, 78 insertions(+), 46 deletions(-) diff --git a/src/renderer/webgl/Utils.js b/src/renderer/webgl/Utils.js index d551fead0..99436a6ed 100644 --- a/src/renderer/webgl/Utils.js +++ b/src/renderer/webgl/Utils.js @@ -22,7 +22,7 @@ module.exports = { * @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 * - * @return {number} [description] + * @return {number} The packed RGBA values as a Uint32. */ getTintFromFloats: function (r, g, b, a) { diff --git a/src/renderer/webgl/WebGLRenderer.js b/src/renderer/webgl/WebGLRenderer.js index 50dc7b95b..84b928445 100644 --- a/src/renderer/webgl/WebGLRenderer.js +++ b/src/renderer/webgl/WebGLRenderer.js @@ -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 * @since 3.0.0 * * @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 {number} x - [description] + * @param {number} x - The 1f value to set on the named uniform. * * @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 * @since 3.0.0 * * @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 {number} x - [description] - * @param {number} y - [description] + * @param {number} x - The 2f x value to set on the named uniform. + * @param {number} y - The 2f y value to set on the named uniform. * * @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 * @since 3.0.0 * * @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 {number} x - [description] - * @param {number} y - [description] - * @param {number} z - [description] + * @param {number} x - The 3f x value to set on the named uniform. + * @param {number} y - The 3f y value to set on the named uniform. + * @param {number} z - The 3f z value to set on the named uniform. * * @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 * @since 3.0.0 * * @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 {number} x - X component - * @param {number} y - Y component - * @param {number} z - Z component - * @param {number} w - W component + * @param {number} x - The 4f x value to set on the named uniform. + * @param {number} y - The 4f y value to set on the named uniform. + * @param {number} z - The 4f z value to set on the named uniform. + * @param {number} w - The 4f w value to set on the named uniform. * * @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 * @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 * @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 * @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 * @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 * @since 3.0.0 * * @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 {integer} x - [description] + * @param {integer} x - The 1i value to set on the named uniform. * * @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 * @since 3.0.0 * * @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 {integer} x - The new X component - * @param {integer} y - The new Y component + * @param {integer} x - The 2i x value to set on the named uniform. + * @param {integer} y - The 2i y value to set on the named uniform. * * @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 * @since 3.0.0 * * @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 {integer} x - The new X component - * @param {integer} y - The new Y component - * @param {integer} z - The new Z component + * @param {integer} x - The 3i x value to set on the named uniform. + * @param {integer} y - The 3i y value to set on the named uniform. + * @param {integer} z - The 3i z value to set on the named uniform. * * @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 * @since 3.0.0 * * @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 {integer} x - X component - * @param {integer} y - Y component - * @param {integer} z - Z component - * @param {integer} w - W component + * @param {integer} x - The 4i x value to set on the named uniform. + * @param {integer} y - The 4i y value to set on the named uniform. + * @param {integer} z - The 4i z value to set on the named uniform. + * @param {integer} w - The 4i w value to set on the named uniform. * * @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 * @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 {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 {Float32Array} matrix - The new matrix value. + * @param {Float32Array} matrix - A Float32Array or sequence of 4 float values. * * @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 * @since 3.0.0 * * @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 {boolean} transpose - [description] - * @param {Float32Array} matrix - [description] + * @param {boolean} transpose - The value indicating whether to transpose the matrix. Must be false. + * @param {Float32Array} matrix - A Float32Array or sequence of 9 float values. * * @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 * @since 3.0.0 * * @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 {boolean} transpose - Is the matrix transposed - * @param {Float32Array} matrix - Matrix data + * @param {boolean} transpose - The value indicating whether to transpose the matrix. Must be false. + * @param {Float32Array} matrix - A Float32Array or sequence of 16 float values. * * @return {this} This WebGL Renderer instance. */ diff --git a/src/renderer/webgl/pipelines/BitmapMaskPipeline.js b/src/renderer/webgl/pipelines/BitmapMaskPipeline.js index 998814a0a..9d9870c18 100644 --- a/src/renderer/webgl/pipelines/BitmapMaskPipeline.js +++ b/src/renderer/webgl/pipelines/BitmapMaskPipeline.js @@ -126,21 +126,23 @@ var BitmapMaskPipeline = new Class({ }, /** - * [description] + * Resizes this pipeline and updates the projection. * * @method Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#resize * @since 3.0.0 * - * @param {number} width - [description] - * @param {number} height - [description] - * @param {number} resolution - [description] + * @param {number} width - The new width. + * @param {number} height - The new height. + * @param {number} resolution - The resolution. * * @return {this} This WebGLPipeline instance. */ resize: function (width, height, resolution) { WebGLPipeline.prototype.resize.call(this, width, height, resolution); + this.resolutionDirty = true; + return this; }, @@ -153,7 +155,7 @@ var BitmapMaskPipeline = new Class({ * * @param {Phaser.GameObjects.GameObject} mask - GameObject used as mask. * @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) { From 1411d5514b53195ee4ab54cb9047bcddbce39b07 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Tue, 4 Feb 2020 17:30:31 +0000 Subject: [PATCH 21/23] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea6dc7ce9..e2a4af1ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,10 @@ The following sections now have 100% complete JSDoc coverage: * Animations +* Create * Geom * Math +* Renderer * Textures ### Removed From 0b696ebc740a6ff106027fca5a8023aebd6677ec Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Tue, 4 Feb 2020 21:13:44 +0000 Subject: [PATCH 22/23] Added `MatterJS.BodyType` to `GameObject.body` type. Fix #4962 --- CHANGELOG.md | 1 + src/gameobjects/GameObject.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2a4af1ea..503b0660d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ The following features are now deprecated and will be removed in a future versio * `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. * `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 diff --git a/src/gameobjects/GameObject.js b/src/gameobjects/GameObject.js index 99c8094bc..88e1c03ba 100644 --- a/src/gameobjects/GameObject.js +++ b/src/gameobjects/GameObject.js @@ -166,10 +166,10 @@ var GameObject = new Class({ this.input = null; /** - * If this Game Object is enabled for Arcade 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 - * @type {?(object|Phaser.Physics.Arcade.Body)} + * @type {?(object|Phaser.Physics.Arcade.Body|MatterJS.BodyType)} * @default null * @since 3.0.0 */ From 58d40fa9e027251608043013e49c6ac72deda73d Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Tue, 4 Feb 2020 23:56:50 +0000 Subject: [PATCH 23/23] Cache the vars --- src/physics/arcade/Body.js | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/physics/arcade/Body.js b/src/physics/arcade/Body.js index bab5472d8..37155b34c 100644 --- a/src/physics/arcade/Body.js +++ b/src/physics/arcade/Body.js @@ -907,23 +907,27 @@ var Body = new Class({ resetFlags: function () { // Store and reset collision flags - this.wasTouching.none = this.touching.none; - this.wasTouching.up = this.touching.up; - this.wasTouching.down = this.touching.down; - this.wasTouching.left = this.touching.left; - this.wasTouching.right = this.touching.right; + var wasTouching = this.wasTouching; + var touching = this.touching; + var blocked = this.blocked; - this.touching.none = true; - this.touching.up = false; - this.touching.down = false; - this.touching.left = false; - this.touching.right = false; + wasTouching.none = touching.none; + wasTouching.up = touching.up; + wasTouching.down = touching.down; + wasTouching.left = touching.left; + wasTouching.right = touching.right; - this.blocked.none = true; - this.blocked.up = false; - this.blocked.down = false; - this.blocked.left = false; - this.blocked.right = false; + touching.none = true; + touching.up = false; + touching.down = false; + touching.left = false; + touching.right = false; + + blocked.none = true; + blocked.up = false; + blocked.down = false; + blocked.left = false; + blocked.right = false; this.overlapR = 0; this.overlapX = 0;