Normalize some typedefs and var declarations

Don't show in changelog
This commit is contained in:
Florian Rival
2020-12-24 14:18:13 +01:00
parent da6aa18963
commit 0e4474c81d
4 changed files with 24 additions and 21 deletions

View File

@@ -132,9 +132,7 @@ gdjs.PixiFiltersTools.rgbOrHexToHexNumber = function (value) {
*/
/**
* A wrapper allowing to create a PIXI filter and update it using a common interface
* @typedef gdjsPixiFiltersToolsFilterCreator
* @type {Object}
* @typedef {Object} gdjsPixiFiltersToolsFilterCreator A wrapper allowing to create a PIXI filter and update it using a common interface
* @property {gdjsPixiFiltersToolsFilterCreatorMakePIXIFilter} makePIXIFilter Function to call to create the filter
* @property {gdjsPixiFiltersToolsUpdate} update The function to be called to update the filter at every frame
* @property {gdjsPixiFiltersToolsUpdateDoubleParameter} updateDoubleParameter The function to be called to update a parameter (with a number)
@@ -143,9 +141,7 @@ gdjs.PixiFiltersTools.rgbOrHexToHexNumber = function (value) {
*/
/**
* The type of a filter used to manipulate a Pixi filter.
* @typedef gdjsPixiFiltersToolsFilter
* @type {Object}
* @typedef {Object} gdjsPixiFiltersToolsFilter The type of a filter used to manipulate a Pixi filter.
* @property {any} pixiFilter The PIXI filter
* @property {gdjsPixiFiltersToolsUpdate} update The function to be called to update the filter at every frame
* @property {gdjsPixiFiltersToolsUpdateDoubleParameter} updateDoubleParameter The function to be called to update a parameter (with a number)

View File

@@ -51,6 +51,7 @@ gdjs.Profiler.prototype.begin = function(sectionName) {
this._currentSection.lastStartTime = this._getTimeNow();
};
/** @param {string=} sectionName */
gdjs.Profiler.prototype.end = function(sectionName) {
// Stop the timer
var sectionTime = this._getTimeNow() - this._currentSection.lastStartTime;
@@ -144,8 +145,8 @@ gdjs.Profiler.prototype.getStats = function() {
* Useful for ingame profiling.
*
* @param {string} sectionName The name of the section
* @param {s} profilerSection The section measures
* @param {*} outputs The array where to push the results
* @param {any} profilerSection The section measures
* @param {any} outputs The array where to push the results
*/
gdjs.Profiler.getProfilerSectionTexts = function(
sectionName,

View File

@@ -5,7 +5,7 @@
*/
/**
* @typedef BehaviorData Properties to set up a behavior.
* @typedef {Object} BehaviorData Properties to set up a behavior.
* @property {string} name The name of the behavior (for getting from an object (object.getBehavior) for example)
* @property {string} type The behavior type. Used by GDJS to find the proper behavior to construct.
*/

View File

@@ -124,14 +124,16 @@ gdjs.SpriteAnimationFrame = function(imageManager, frameData)
//Load the custom collision mask, if any:
if ( frameData.hasCustomCollisionMask ) {
this.hasCustomHitBoxes = true;
for(var i = 0, len = frameData.customCollisionMask.length;i<len;++i) {
var i = 0;
for(var len = frameData.customCollisionMask.length;i<len;++i) {
/** @type {Array<SpritePoint>} */
var polygonData = frameData.customCollisionMask[i];
//Add a polygon, if necessary (Avoid recreating a polygon if it already exists).
if ( i >= this.customHitBoxes.length ) this.customHitBoxes.push(new gdjs.Polygon());
for(var j = 0, len2 = polygonData.length;j<len2;++j) {
var j = 0;
for(var len2 = polygonData.length;j<len2;++j) {
/** @type {SpritePoint} */
var pointData = polygonData[j];
@@ -186,7 +188,8 @@ gdjs.SpriteAnimationDirection = function(imageManager, directionData)
/** @type {Array<SpriteAnimationFrame>} */
this.frames = [];
}
for(var i = 0, len = directionData.sprites.length;i<len;++i) {
var i = 0;
for(var len = directionData.sprites.length;i<len;++i) {
/** @type {SpriteFrameData} */
var frameData = directionData.sprites[i];
@@ -215,7 +218,8 @@ gdjs.SpriteAnimation = function(imageManager, animData)
/** @type {Array<gdjs.SpriteAnimationDirection>} */
if ( this.directions === undefined ) this.directions = [];
for(var i = 0, len = animData.directions.length;i<len;++i) {
var i = 0;
for(var len = animData.directions.length;i<len;++i) {
/** @type {SpriteDirectionData} */
var directionData = animData.directions[i];
@@ -289,7 +293,7 @@ gdjs.SpriteRuntimeObject = function(runtimeScene, spriteObjectData) {
* call `this._updateAnimationFrame()`.
* Can be null, so ensure that this case is handled properly.
*
* @type {gdjs.SpriteAnimationFrame}
* @type {?gdjs.SpriteAnimationFrame}
*/
this._animationFrame = null;
@@ -313,10 +317,12 @@ gdjs.registerObject("Sprite", gdjs.SpriteRuntimeObject); //Notify gdjs of the ob
/**
* @param {SpriteObjectData} oldObjectData
* @param {SpriteObjectData} newObjectData
* @returns {boolean}
*/
gdjs.SpriteRuntimeObject.prototype.updateFromObjectData = function(oldObjectData, newObjectData) {
var runtimeScene = this._runtimeScene;
for(var i = 0, len = newObjectData.animations.length;i<len;++i) {
var i = 0;
for(var len = newObjectData.animations.length;i<len;++i) {
var animData = newObjectData.animations[i];
if ( i < this._animations.length )
@@ -528,7 +534,7 @@ gdjs.SpriteRuntimeObject.prototype.isCurrentAnimationName = function(name) {
/**
* Change the angle (or direction index) of the object
* @return {number} The new angle (or direction index) to be applied
* @param {number} The new angle (or direction index) to be applied
*/
gdjs.SpriteRuntimeObject.prototype.setDirectionOrAngle = function(newValue) {
if ( this._currentAnimation >= this._animations.length ) {
@@ -677,10 +683,10 @@ gdjs.SpriteRuntimeObject.prototype.getPointY = function(name) {
*
* All transformations (flipping, scale, rotation) are supported.
*
* @param {number} pointX The X position of the point, in object coordinates.
* @param {number} pointY The Y position of the point, in object coordinates.
* @param {Array} result Array that will be updated with the result (x and y position of the point
* in global coordinates)
* @param {number} x The X position of the point, in object coordinates.
* @param {number} y The Y position of the point, in object coordinates.
* @param {Array<number>} result Array that will be updated with the result
* (x and y position of the point in global coordinates).
* @private
*/
gdjs.SpriteRuntimeObject.prototype._transformToGlobal = function(x, y, result) {
@@ -838,7 +844,7 @@ gdjs.SpriteRuntimeObject.prototype.setAngle = function(angle) {
* Get the angle of the object.
* @return {number} The angle, in degrees.
*/
gdjs.SpriteRuntimeObject.prototype.getAngle = function(angle) {
gdjs.SpriteRuntimeObject.prototype.getAngle = function() {
if ( this._currentAnimation >= this._animations.length ) {
return 0;
}