mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Autoformat runtimebehavior.js and separate typedefs into separate comments for easier parsing
Don't show in changelog
This commit is contained in:
@@ -8,8 +8,10 @@
|
||||
* @property {string} content.fontFamily The font of the text
|
||||
* @property {number} content.fontSize The size of the text
|
||||
* @property {boolean} content.wordWrap Activate word wrap if set to true
|
||||
* @property {('left'|'center'|'right')} content.align Alignment of the text: "left", "center" or "right"
|
||||
*
|
||||
* @property {'left'|'center'|'right'} content.align Alignment of the text: "left", "center" or "right"
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {ObjectData & BBTextObjectDataType} BBTextObjectData
|
||||
*/
|
||||
|
||||
|
@@ -5,7 +5,9 @@
|
||||
* @property {string} content.color A string representing color in hexadecimal format.
|
||||
* @property {string} content.texture A string representing the name of texture used for light object.
|
||||
* @property {boolean} content.debugMode true if the light objects shows debug graphics, false otherwise.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {ObjectData & LightObjectDataType} LightObjectData
|
||||
*/
|
||||
|
||||
|
@@ -13,7 +13,9 @@
|
||||
* @property {number} width The object width
|
||||
* @property {number} height The object height
|
||||
* @property {string} texture The name of the resource containing the texture to use
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {ObjectData & PanelSpriteObjectDataType} PanelSpriteObjectData
|
||||
*/
|
||||
|
||||
|
@@ -36,7 +36,9 @@
|
||||
* @property {number} flow
|
||||
* @property {number} tank
|
||||
* @property {boolean} destroyWhenNoParticles Destroy the object when there is no particles?
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {ObjectData & ParticleEmitterObjectDataType} ParticleEmitterObjectData
|
||||
*/
|
||||
|
||||
|
@@ -19,7 +19,9 @@
|
||||
* @property {number} outlineSize The size of the outline of the painted shape, in pixels.
|
||||
* @property {boolean} absoluteCoordinates Use absolute coordinates?
|
||||
* @property {boolean} clearBetweenFrames Clear the previous render before the next draw?
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {ObjectData & ShapePainterObjectDataType} ShapePainterObjectData
|
||||
*/
|
||||
|
||||
|
@@ -15,7 +15,9 @@
|
||||
* @property {number} color.g The Green level from 0 to 255
|
||||
* @property {number} color.b The Blue level from 0 to 255
|
||||
* @property {string} string The text of the object
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {ObjectData & TextObjectDataType} TextObjectData
|
||||
*/
|
||||
|
||||
|
@@ -7,7 +7,9 @@
|
||||
* @typedef {Object} TiledSpriteObjectDataType Initial properties for a Tiled Sprite object
|
||||
* @property {number} width The width of the object
|
||||
* @property {number} height The height of the object
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {ObjectData & TiledSpriteObjectDataType} TiledSpriteObjectData
|
||||
*/
|
||||
|
||||
|
@@ -5,7 +5,9 @@
|
||||
* @property {boolean} content.loop Does the video loops itself?
|
||||
* @property {number} content.volume The volume of the video
|
||||
* @property {string} content.videoResource Name of the resource corresponding to the video
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {ObjectData & VideoObjectDataType} VideoObjectData
|
||||
*/
|
||||
|
||||
|
@@ -19,13 +19,14 @@
|
||||
* @param {BehaviorData} behaviorData The properties used to setup the behavior
|
||||
* @param {gdjs.RuntimeObject} owner The object owning the behavior
|
||||
*/
|
||||
gdjs.RuntimeBehavior = function(runtimeScene, behaviorData, owner)
|
||||
{
|
||||
this.name = behaviorData.name || "";
|
||||
this.type = behaviorData.type || "";
|
||||
this._nameId = gdjs.RuntimeObject.getNameIdentifier(this.name);
|
||||
this._activated = true;
|
||||
this.owner = owner;
|
||||
gdjs.RuntimeBehavior = function (runtimeScene, behaviorData, owner) {
|
||||
this.name = behaviorData.name || '';
|
||||
this.type = behaviorData.type || '';
|
||||
this._nameId = gdjs.RuntimeObject.getNameIdentifier(this.name);
|
||||
this._activated = true;
|
||||
|
||||
/** @type {gdjs.RuntimeObject} */
|
||||
this.owner = owner;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -38,25 +39,28 @@ gdjs.RuntimeBehavior = function(runtimeScene, behaviorData, owner)
|
||||
* @param {BehaviorData} newBehaviorData The new data for the behavior.
|
||||
* @returns {boolean} true if the behavior was updated, false if it could not (i.e: hot-reload is not supported).
|
||||
*/
|
||||
gdjs.RuntimeBehavior.prototype.updateFromBehaviorData = function(oldBehaviorData, newBehaviorData) {
|
||||
// If not redefined, mark by default the hot-reload as failed.
|
||||
return false;
|
||||
}
|
||||
gdjs.RuntimeBehavior.prototype.updateFromBehaviorData = function (
|
||||
oldBehaviorData,
|
||||
newBehaviorData
|
||||
) {
|
||||
// If not redefined, mark by default the hot-reload as failed.
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the name of the behavior.
|
||||
* @return {string} The behavior's name.
|
||||
*/
|
||||
gdjs.RuntimeBehavior.prototype.getName = function() {
|
||||
return this.name;
|
||||
gdjs.RuntimeBehavior.prototype.getName = function () {
|
||||
return this.name;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the name identifier of the behavior.
|
||||
* @return {number} The behavior's name identifier.
|
||||
*/
|
||||
gdjs.RuntimeBehavior.prototype.getNameId = function() {
|
||||
return this._nameId;
|
||||
gdjs.RuntimeBehavior.prototype.getNameId = function () {
|
||||
return this._nameId;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -64,15 +68,15 @@ gdjs.RuntimeBehavior.prototype.getNameId = function() {
|
||||
* Behaviors writers: Please do not redefine this method. Redefine doStepPreEvents instead.
|
||||
* @param {gdjs.RuntimeScene} runtimeScene The runtimeScene owning the object
|
||||
*/
|
||||
gdjs.RuntimeBehavior.prototype.stepPreEvents = function(runtimeScene) {
|
||||
if ( this._activated ) {
|
||||
var profiler = runtimeScene.getProfiler();
|
||||
if (profiler) profiler.begin(this.name);
|
||||
gdjs.RuntimeBehavior.prototype.stepPreEvents = function (runtimeScene) {
|
||||
if (this._activated) {
|
||||
var profiler = runtimeScene.getProfiler();
|
||||
if (profiler) profiler.begin(this.name);
|
||||
|
||||
this.doStepPreEvents(runtimeScene);
|
||||
this.doStepPreEvents(runtimeScene);
|
||||
|
||||
if (profiler) profiler.end(this.name);
|
||||
}
|
||||
if (profiler) profiler.end(this.name);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -80,31 +84,30 @@ gdjs.RuntimeBehavior.prototype.stepPreEvents = function(runtimeScene) {
|
||||
* Behaviors writers: Please do not redefine this method. Redefine doStepPreEvents instead.
|
||||
* @param {gdjs.RuntimeScene} runtimeScene The runtimeScene owning the object
|
||||
*/
|
||||
gdjs.RuntimeBehavior.prototype.stepPostEvents = function(runtimeScene) {
|
||||
if ( this._activated ) {
|
||||
var profiler = runtimeScene.getProfiler();
|
||||
if (profiler) profiler.begin(this.name);
|
||||
gdjs.RuntimeBehavior.prototype.stepPostEvents = function (runtimeScene) {
|
||||
if (this._activated) {
|
||||
var profiler = runtimeScene.getProfiler();
|
||||
if (profiler) profiler.begin(this.name);
|
||||
|
||||
this.doStepPostEvents(runtimeScene);
|
||||
this.doStepPostEvents(runtimeScene);
|
||||
|
||||
if (profiler) profiler.end(this.name);
|
||||
}
|
||||
if (profiler) profiler.end(this.name);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* De/Activate the behavior
|
||||
* @param {boolean} enable true to enable the behavior, false to disable it
|
||||
*/
|
||||
gdjs.RuntimeBehavior.prototype.activate = function(enable) {
|
||||
if ( enable === undefined ) enable = true;
|
||||
if ( !this._activated && enable ) {
|
||||
this._activated = true;
|
||||
this.onActivate();
|
||||
}
|
||||
else if ( this._activated && !enable ) {
|
||||
this._activated = false;
|
||||
this.onDeActivate();
|
||||
}
|
||||
gdjs.RuntimeBehavior.prototype.activate = function (enable) {
|
||||
if (enable === undefined) enable = true;
|
||||
if (!this._activated && enable) {
|
||||
this._activated = true;
|
||||
this.onActivate();
|
||||
} else if (this._activated && !enable) {
|
||||
this._activated = false;
|
||||
this.onDeActivate();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -112,47 +115,37 @@ gdjs.RuntimeBehavior.prototype.activate = function(enable) {
|
||||
* object using it was created), after the object is fully initialized (so
|
||||
* you can use `this.owner` without risk).
|
||||
*/
|
||||
gdjs.RuntimeBehavior.prototype.onCreated = function() {
|
||||
|
||||
};
|
||||
gdjs.RuntimeBehavior.prototype.onCreated = function () {};
|
||||
|
||||
/**
|
||||
* Return true if the behavior is activated
|
||||
*/
|
||||
gdjs.RuntimeBehavior.prototype.activated = function() {
|
||||
return this._activated;
|
||||
gdjs.RuntimeBehavior.prototype.activated = function () {
|
||||
return this._activated;
|
||||
};
|
||||
|
||||
/**
|
||||
* Reimplement this method to do extra work when the behavior is activated (after
|
||||
* it has been deactivated, see `onDeActivate`).
|
||||
*/
|
||||
gdjs.RuntimeBehavior.prototype.onActivate = function() {
|
||||
|
||||
};
|
||||
gdjs.RuntimeBehavior.prototype.onActivate = function () {};
|
||||
|
||||
/**
|
||||
* Reimplement this method to do extra work when the behavior is deactivated.
|
||||
*/
|
||||
gdjs.RuntimeBehavior.prototype.onDeActivate = function() {
|
||||
|
||||
};
|
||||
gdjs.RuntimeBehavior.prototype.onDeActivate = function () {};
|
||||
|
||||
/**
|
||||
* This method is called each tick before events are done.
|
||||
* @param {gdjs.RuntimeScene} runtimeScene The runtimeScene owning the object
|
||||
*/
|
||||
gdjs.RuntimeBehavior.prototype.doStepPreEvents = function(runtimeScene) {
|
||||
|
||||
};
|
||||
gdjs.RuntimeBehavior.prototype.doStepPreEvents = function (runtimeScene) {};
|
||||
|
||||
/**
|
||||
* This method is called each tick after events are done.
|
||||
* @param {gdjs.RuntimeScene} runtimeScene The runtimeScene owning the object
|
||||
*/
|
||||
gdjs.RuntimeBehavior.prototype.doStepPostEvents = function(runtimeScene) {
|
||||
|
||||
}
|
||||
gdjs.RuntimeBehavior.prototype.doStepPostEvents = function (runtimeScene) {};
|
||||
|
||||
/**
|
||||
* This method is called when the owner of the behavior
|
||||
@@ -161,17 +154,13 @@ gdjs.RuntimeBehavior.prototype.doStepPostEvents = function(runtimeScene) {
|
||||
* hot-reloading only. Otherwise, behaviors are just de-activated,
|
||||
* not removed. See `onDeActivate`).
|
||||
*/
|
||||
gdjs.RuntimeBehavior.prototype.onDestroy = function() {
|
||||
|
||||
};
|
||||
gdjs.RuntimeBehavior.prototype.onDestroy = function () {};
|
||||
|
||||
/**
|
||||
* This method is called when the owner of the behavior
|
||||
* was hot reloaded, so its position, angle, size can have been changed outside
|
||||
* of events.
|
||||
*/
|
||||
gdjs.RuntimeBehavior.prototype.onObjectHotReloaded = function() {
|
||||
gdjs.RuntimeBehavior.prototype.onObjectHotReloaded = function () {};
|
||||
|
||||
};
|
||||
|
||||
gdjs.registerBehavior("", gdjs.RuntimeBehavior);
|
||||
gdjs.registerBehavior('', gdjs.RuntimeBehavior);
|
||||
|
@@ -53,7 +53,9 @@
|
||||
* @typedef {Object} SpriteObjectDataType Represents the data of a {@link gdjs.SpriteRuntimeObject}.
|
||||
* @property {boolean} updateIfNotVisible Update the object even if he is not visible?.
|
||||
* @property {Array<SpriteAnimationData>} animations The list of {@link SpriteAnimationData} representing {@link gdjs.SpriteAnimation} instances.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {ObjectData & SpriteObjectDataType} SpriteObjectData
|
||||
*/
|
||||
|
||||
|
Reference in New Issue
Block a user