mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Add TypeScript checks to gdjs.RuntimeScene, gdjs
Only show in developer changelog
This commit is contained in:

committed by
Florian Rival

parent
37c260c19d
commit
5f54583ff5
@@ -8,8 +8,15 @@ describe('gdjs.DraggableRuntimeBehavior', function() {
|
||||
});
|
||||
var runtimeScene = new gdjs.RuntimeScene(runtimeGame);
|
||||
runtimeScene.loadFromScene({
|
||||
layers:[{name:"", visibility: true, effects: []}],
|
||||
layers:[{name:"", visibility: true, cameras: [], effects: []}],
|
||||
variables: [],
|
||||
r: 0,
|
||||
v: 0,
|
||||
b: 0,
|
||||
mangledName: 'Scene1',
|
||||
name: 'Scene1',
|
||||
stopSoundsOnStartup: false,
|
||||
title: '',
|
||||
behaviorsSharedData: [],
|
||||
objects: [],
|
||||
instances: []
|
||||
|
@@ -187,3 +187,14 @@ gdjs.RuntimeSceneCocosRenderer.prototype.showCursor = function() {
|
||||
gdjs.RuntimeSceneCocosRenderer.prototype.getCocosScene = function() {
|
||||
return this._cocosScene;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {gdjs.Layer} layer
|
||||
* @param {number} index
|
||||
*/
|
||||
gdjs.RuntimeSceneCocosRenderer.prototype.setLayerIndex = function (
|
||||
layer,
|
||||
index
|
||||
) {
|
||||
// Not implemented
|
||||
}
|
||||
|
@@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
/*
|
||||
* GDevelop JS Platform
|
||||
* Copyright 2013-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
|
||||
@@ -8,26 +9,29 @@
|
||||
* The `gdjs` namespace contains all classes and objects of the game engine.
|
||||
* @namespace
|
||||
*/
|
||||
window.gdjs = {
|
||||
objectsTypes: new Hashtable(),
|
||||
behaviorsTypes: new Hashtable(),
|
||||
/**
|
||||
* Contains functions used by events (this is a convention only, functions can actually
|
||||
* be anywhere).
|
||||
* @namespace
|
||||
* @memberOf gdjs
|
||||
*/
|
||||
evtTools: {},
|
||||
callbacksFirstRuntimeSceneLoaded: [],
|
||||
callbacksRuntimeSceneLoaded: [],
|
||||
callbacksRuntimeScenePreEvents: [],
|
||||
callbacksRuntimeScenePostEvents: [],
|
||||
callbacksRuntimeScenePaused: [],
|
||||
callbacksRuntimeSceneResumed: [],
|
||||
callbacksRuntimeSceneUnloading: [],
|
||||
callbacksRuntimeSceneUnloaded: [],
|
||||
callbacksObjectDeletedFromScene: [],
|
||||
};
|
||||
// @ts-ignore - creating the global object acting as a namespace
|
||||
window.gdjs = {};
|
||||
|
||||
/**
|
||||
* Contains functions used by events (this is a convention only, functions can actually
|
||||
* be anywhere).
|
||||
* @namespace
|
||||
* @memberOf gdjs
|
||||
*/
|
||||
gdjs.evtTools = {};
|
||||
|
||||
gdjs.objectsTypes = new Hashtable();
|
||||
gdjs.behaviorsTypes = new Hashtable();
|
||||
|
||||
/** @type {Function[]} */ gdjs.callbacksFirstRuntimeSceneLoaded = [];
|
||||
/** @type {Function[]} */ gdjs.callbacksRuntimeSceneLoaded = [];
|
||||
/** @type {Function[]} */ gdjs.callbacksRuntimeScenePreEvents = [];
|
||||
/** @type {Function[]} */ gdjs.callbacksRuntimeScenePostEvents = [];
|
||||
/** @type {Function[]} */ gdjs.callbacksRuntimeScenePaused = [];
|
||||
/** @type {Function[]} */ gdjs.callbacksRuntimeSceneResumed = [];
|
||||
/** @type {Function[]} */ gdjs.callbacksRuntimeSceneUnloading = [];
|
||||
/** @type {Function[]} */ gdjs.callbacksRuntimeSceneUnloaded = [];
|
||||
/** @type {Function[]} */ gdjs.callbacksObjectDeletedFromScene = [];
|
||||
|
||||
/**
|
||||
* Convert a rgb color value to a hex string.
|
||||
@@ -123,14 +127,6 @@ gdjs.toDegrees = function (angleInRadians) {
|
||||
return (angleInRadians * 180) / 3.14159;
|
||||
};
|
||||
|
||||
/**
|
||||
* A Constructor for a {@link gdjs.RuntimeObject}.
|
||||
* @name RuntimeObjectConstructor
|
||||
* @function
|
||||
* @param {gdjs.RuntimeScene} runtimeScene The {@link gdjs.RuntimeScene} the object belongs to.
|
||||
* @param {ObjectData} objectData The initial properties of the object.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Register a runtime object (class extending {@link gdjs.RuntimeObject}) that can be used in a scene.
|
||||
*
|
||||
@@ -139,21 +135,12 @@ gdjs.toDegrees = function (angleInRadians) {
|
||||
* of the type of the object is "TextObject::Text".
|
||||
*
|
||||
* @param {string} objectTypeName The name of the type of the Object.
|
||||
* @param {RuntimeObjectConstructor} Ctor The constructor of the Object.
|
||||
* @param {typeof gdjs.RuntimeObject} Ctor The constructor of the Object.
|
||||
*/
|
||||
gdjs.registerObject = function (objectTypeName, Ctor) {
|
||||
gdjs.objectsTypes.put(objectTypeName, Ctor);
|
||||
};
|
||||
|
||||
/**
|
||||
* A Constructor for a {@link gdjs.RuntimeBehavior}.
|
||||
* @name RuntimeBehaviorConstructor
|
||||
* @function
|
||||
* @param {gdjs.RuntimeScene} runtimeScene The scene owning the object of the behavior
|
||||
* @param {BehaviorData} behaviorData The properties used to setup the behavior
|
||||
* @param {gdjs.RuntimeObject} owner The object owning the behavior
|
||||
*/
|
||||
|
||||
/**
|
||||
* Register a runtime behavior (class extending {@link gdjs.RuntimeBehavior}) that can be used by a
|
||||
* {@link gdjs.RuntimeObject}.
|
||||
@@ -163,7 +150,7 @@ gdjs.registerObject = function (objectTypeName, Ctor) {
|
||||
* the full name of the type of the behavior is "DraggableBehavior::Draggable".
|
||||
*
|
||||
* @param {string} behaviorTypeName The name of the type of the behavior.
|
||||
* @param {RuntimeBehaviorConstructor} Ctor The constructor of the Object.
|
||||
* @param {typeof gdjs.RuntimeBehavior} Ctor The constructor of the Object.
|
||||
*/
|
||||
gdjs.registerBehavior = function (behaviorTypeName, Ctor) {
|
||||
gdjs.behaviorsTypes.put(behaviorTypeName, Ctor);
|
||||
@@ -258,7 +245,7 @@ gdjs.registerObjectDeletedFromSceneCallback = function (callback) {
|
||||
* @private
|
||||
*/
|
||||
gdjs.registerGlobalCallbacks = function () {
|
||||
console.warning(
|
||||
console.warn(
|
||||
"You're calling gdjs.registerGlobalCallbacks. This method is now useless and you must not call it anymore."
|
||||
);
|
||||
};
|
||||
@@ -284,7 +271,7 @@ gdjs.clearGlobalCallbacks = function () {
|
||||
* Get the constructor of an object.
|
||||
*
|
||||
* @param {string} name The name of the type of the object.
|
||||
* @returns {ObjectCtor}
|
||||
* @returns {typeof gdjs.RuntimeObject}
|
||||
*/
|
||||
gdjs.getObjectConstructor = function (name) {
|
||||
if (name !== undefined && gdjs.objectsTypes.containsKey(name))
|
||||
@@ -298,7 +285,7 @@ gdjs.getObjectConstructor = function (name) {
|
||||
* Get the constructor of a behavior.
|
||||
*
|
||||
* @param {string} name The name of the type of the behavior.
|
||||
* @returns {BehaviorCtor}
|
||||
* @returns {typeof gdjs.RuntimeBehavior}
|
||||
*/
|
||||
gdjs.getBehaviorConstructor = function (name) {
|
||||
if (name !== undefined && gdjs.behaviorsTypes.containsKey(name))
|
||||
@@ -383,13 +370,13 @@ gdjs.filterPickedObjectsList = function (arr) {
|
||||
* @param {Array<any>} src The source array
|
||||
* @param {Array<any>} dst The destination array
|
||||
*/
|
||||
gdjs.copyArray = function(src, dst) {
|
||||
gdjs.copyArray = function (src, dst) {
|
||||
var len = src.length;
|
||||
for (var i = 0; i < len; ++i) {
|
||||
dst[i] = src[i];
|
||||
}
|
||||
dst.length = len;
|
||||
}
|
||||
};
|
||||
|
||||
//Make sure console.warn and console.error are available.
|
||||
console.warn = console.warn || console.log;
|
||||
|
@@ -34,6 +34,10 @@ gdjs.RuntimeScenePixiRenderer.prototype.onGameResolutionResized = function () {
|
||||
this._pixiRenderer.height / runtimeGame.getGameResolutionHeight();
|
||||
};
|
||||
|
||||
gdjs.RuntimeScenePixiRenderer.prototype.onSceneUnloaded = function () {
|
||||
// Nothing to do.
|
||||
};
|
||||
|
||||
gdjs.RuntimeScenePixiRenderer.prototype.render = function () {
|
||||
if (!this._pixiRenderer) return;
|
||||
|
||||
@@ -45,7 +49,8 @@ gdjs.RuntimeScenePixiRenderer.prototype.render = function () {
|
||||
};
|
||||
|
||||
gdjs.RuntimeScenePixiRenderer.prototype._renderProfileText = function () {
|
||||
if (!this._runtimeScene.getProfiler()) return;
|
||||
var profiler = this._runtimeScene.getProfiler();
|
||||
if (!profiler) return;
|
||||
|
||||
if (!this._profilerText) {
|
||||
this._profilerText = new PIXI.Text(' ', {
|
||||
@@ -57,7 +62,7 @@ gdjs.RuntimeScenePixiRenderer.prototype._renderProfileText = function () {
|
||||
this._pixiContainer.addChild(this._profilerText);
|
||||
}
|
||||
|
||||
var average = this._runtimeScene.getProfiler().getFramesAverageMeasures();
|
||||
var average = profiler.getFramesAverageMeasures();
|
||||
var outputs = [];
|
||||
gdjs.Profiler.getProfilerSectionTexts('All', average, outputs);
|
||||
|
||||
|
@@ -92,7 +92,7 @@ gdjs.RuntimeObject = function(runtimeScene, objectData) {
|
||||
this._livingOnScene = true;
|
||||
/**
|
||||
* @type {number}
|
||||
* @protected
|
||||
* @readonly
|
||||
*/
|
||||
this.id = runtimeScene.createNewUniqueId();
|
||||
/**
|
||||
@@ -106,6 +106,13 @@ gdjs.RuntimeObject = function(runtimeScene, objectData) {
|
||||
*/
|
||||
this.persistentUuid = null;
|
||||
|
||||
/**
|
||||
* A property to be used by external algorithms to indicate if the
|
||||
* object is picked or not in an object selection. By construction, this is
|
||||
* not "thread safe" or "re-entrant algorithm" safe.
|
||||
*/
|
||||
this.pick = false;
|
||||
|
||||
//Hit boxes:
|
||||
if ( this._defaultHitBoxes === undefined ) {
|
||||
/**
|
||||
|
@@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
/*
|
||||
* GDevelop JS Platform
|
||||
* Copyright 2013-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
|
||||
@@ -21,24 +22,33 @@ gdjs.RuntimeScene = function(runtimeGame)
|
||||
this._layers = new Hashtable();
|
||||
this._initialBehaviorSharedData = new Hashtable();
|
||||
this._renderer = new gdjs.RuntimeSceneRenderer(this,
|
||||
// @ts-ignore - allow no renderer for tests
|
||||
runtimeGame ? runtimeGame.getRenderer() : null);
|
||||
this._variables = new gdjs.VariablesContainer();
|
||||
this._runtimeGame = runtimeGame;
|
||||
this._lastId = 0;
|
||||
this._name = "";
|
||||
this._timeManager = new gdjs.TimeManager(Date.now());
|
||||
this._timeManager = new gdjs.TimeManager();
|
||||
this._gameStopRequested = false;
|
||||
this._requestedScene = "";
|
||||
this._isLoaded = false; // True if loadFromScene was called and the scene is being played.
|
||||
this._isJustResumed = false; // True in the first frame after resuming the paused scene
|
||||
this._requestedChange = gdjs.RuntimeScene.CONTINUE; // What to do after the frame is rendered.
|
||||
|
||||
/** @type gdjs.RuntimeObject[] */
|
||||
this._backgroundColor = 0; // Black background by default.
|
||||
|
||||
/** @type {gdjs.RuntimeObject[]} */
|
||||
this._allInstancesList = []; //An array used to create a list of all instance when necessary ( see _constructListOfAllInstances )
|
||||
|
||||
/** @type gdjs.RuntimeObject[] */
|
||||
this._onceTriggers = new gdjs.OnceTriggers();
|
||||
|
||||
/** @type {Object.<string, number[]>} */
|
||||
this._layersCameraCoordinates = {};
|
||||
|
||||
/** @type {gdjs.RuntimeObject[]} */
|
||||
this._instancesRemoved = []; //The instances removed from the scene and waiting to be sent to the cache.
|
||||
|
||||
/** @type gdjs.Profiler */
|
||||
/** @type {?gdjs.Profiler} */
|
||||
this._profiler = null; // Set to `new gdjs.Profiler()` to have profiling done on the scene.
|
||||
this._onProfilerStopped = null; // The callback function to call when the profiler is stopped.
|
||||
|
||||
@@ -65,11 +75,11 @@ gdjs.RuntimeScene.prototype.onGameResolutionResized = function() {
|
||||
|
||||
/**
|
||||
* Load the runtime scene from the given scene.
|
||||
* @param {Object} sceneData An object containing the scene data.
|
||||
* @param {?LayoutData} sceneData An object containing the scene data.
|
||||
* @see gdjs.RuntimeGame#getSceneData
|
||||
*/
|
||||
gdjs.RuntimeScene.prototype.loadFromScene = function(sceneData) {
|
||||
if ( sceneData === undefined ) {
|
||||
if (!sceneData) {
|
||||
console.error("loadFromScene was called without a scene");
|
||||
return;
|
||||
}
|
||||
@@ -79,9 +89,7 @@ gdjs.RuntimeScene.prototype.loadFromScene = function(sceneData) {
|
||||
//Setup main properties
|
||||
if (this._runtimeGame) this._runtimeGame.getRenderer().setWindowTitle(sceneData.title);
|
||||
this._name = sceneData.name;
|
||||
this.setBackgroundColor(parseInt(sceneData.r, 10),
|
||||
parseInt(sceneData.v, 10),
|
||||
parseInt(sceneData.b, 10));
|
||||
this.setBackgroundColor(sceneData.r, sceneData.v, sceneData.b);
|
||||
|
||||
//Load layers
|
||||
for(var i = 0, len = sceneData.layers.length;i<len;++i) {
|
||||
@@ -104,9 +112,8 @@ gdjs.RuntimeScene.prototype.loadFromScene = function(sceneData) {
|
||||
this.registerObject(initialGlobalObjectsData[i]);
|
||||
}
|
||||
//...then the scene objects
|
||||
this._initialObjectsData = sceneData.objects;
|
||||
for(var i = 0, len = this._initialObjectsData.length;i<len;++i) {
|
||||
this.registerObject(this._initialObjectsData[i]);
|
||||
for(var i = 0, len = sceneData.objects.length;i<len;++i) {
|
||||
this.registerObject(sceneData.objects[i]);
|
||||
}
|
||||
|
||||
//Create initial instances of objects
|
||||
@@ -194,7 +201,7 @@ gdjs.RuntimeScene.prototype.unregisterObject = function(objectName) {
|
||||
}
|
||||
this._objects.remove(objectName);
|
||||
this._instances.remove(objectName);
|
||||
this._instancesCache.put(objectName);
|
||||
this._instancesCache.remove(objectName);
|
||||
this._objectsCtor.remove(objectName);
|
||||
}
|
||||
|
||||
@@ -243,8 +250,7 @@ gdjs.RuntimeScene.prototype.unloadScene = function() {
|
||||
}
|
||||
|
||||
// Notify the renderer
|
||||
if (this._renderer && this._renderer.onSceneUnloaded)
|
||||
this._renderer.onSceneUnloaded();
|
||||
if (this._renderer) this._renderer.onSceneUnloaded();
|
||||
|
||||
// Notify the global callbacks (after notifying objects and renderer, because
|
||||
// callbacks from extensions might want to free resources - which can't be done
|
||||
@@ -261,13 +267,14 @@ gdjs.RuntimeScene.prototype.unloadScene = function() {
|
||||
this._objects = new Hashtable();
|
||||
this._instances = new Hashtable();
|
||||
this._instancesCache = new Hashtable();
|
||||
this._initialObjectsData = null;
|
||||
this._eventsFunction = null;
|
||||
this._objectsCtor = new Hashtable();
|
||||
this._allInstancesList = [];
|
||||
this._instancesRemoved = [];
|
||||
|
||||
this._lastId = 0;
|
||||
|
||||
// @ts-ignore - set to null to force garbage collection.
|
||||
this._onceTriggers = null;
|
||||
|
||||
this._isLoaded = false;
|
||||
@@ -298,9 +305,9 @@ gdjs.RuntimeScene.prototype.createObjectsFrom = function(data, xPos, yPos, track
|
||||
newObject.persistentUuid = instanceData.persistentUuid || null;
|
||||
}
|
||||
|
||||
newObject.setPosition(parseFloat(instanceData.x) + xPos, parseFloat(instanceData.y) + yPos);
|
||||
newObject.setZOrder(parseFloat(instanceData.zOrder));
|
||||
newObject.setAngle(parseFloat(instanceData.angle));
|
||||
newObject.setPosition(instanceData.x + xPos, instanceData.y + yPos);
|
||||
newObject.setZOrder(instanceData.zOrder);
|
||||
newObject.setAngle(instanceData.angle);
|
||||
newObject.setLayer(instanceData.layer);
|
||||
newObject.getVariables().initFrom(instanceData.initialVariables, true);
|
||||
newObject.extraInitializationFromInitialInstance(instanceData);
|
||||
@@ -441,7 +448,6 @@ gdjs.RuntimeScene.prototype._updateLayers = function() {
|
||||
*
|
||||
* Visibility is set to false if object is hidden, or if
|
||||
* object is too far from the camera of its layer ("culling").
|
||||
* @private
|
||||
*/
|
||||
gdjs.RuntimeScene.prototype._updateObjectsVisibility = function() {
|
||||
if (this._timeManager.isFirstFrame()) {
|
||||
@@ -491,8 +497,6 @@ gdjs.RuntimeScene.prototype._updateObjectsVisibility = function() {
|
||||
* and allows the removed objects to be cached (or destroyed if the cache is full).<br>
|
||||
* The removed objects could not be sent directly to the cache, as events may still be using them after
|
||||
* removing them from the scene for example.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
gdjs.RuntimeScene.prototype._cacheOrClearRemovedInstances = function() {
|
||||
for(var k =0, lenk=this._instancesRemoved.length;k<lenk;++k) {
|
||||
@@ -506,7 +510,6 @@ gdjs.RuntimeScene.prototype._cacheOrClearRemovedInstances = function() {
|
||||
|
||||
/**
|
||||
* Tool function filling _allInstancesList member with all the living object instances.
|
||||
* @private
|
||||
*/
|
||||
gdjs.RuntimeScene.prototype._constructListOfAllInstances = function() {
|
||||
var currentListSize = 0;
|
||||
@@ -531,7 +534,6 @@ gdjs.RuntimeScene.prototype._constructListOfAllInstances = function() {
|
||||
|
||||
/**
|
||||
* Update the objects before launching the events.
|
||||
* @private
|
||||
*/
|
||||
gdjs.RuntimeScene.prototype._updateObjectsPreEvents = function() {
|
||||
|
||||
@@ -561,7 +563,6 @@ gdjs.RuntimeScene.prototype._updateObjectsPreEvents = function() {
|
||||
|
||||
/**
|
||||
* Update the objects (update positions, time management...)
|
||||
* @private
|
||||
*/
|
||||
gdjs.RuntimeScene.prototype._updateObjectsPostEvents = function() {
|
||||
this._cacheOrClearRemovedInstances();
|
||||
@@ -658,7 +659,7 @@ gdjs.RuntimeScene.prototype.getObjects = function(name){
|
||||
* Create a new object from its name. The object is also added to the instances
|
||||
* living on the scene ( No need to call RuntimeScene.addObject )
|
||||
* @param {string} objectName The name of the object to be created
|
||||
* @return {gdjs.RuntimeObject} The created object
|
||||
* @return {?gdjs.RuntimeObject} The created object
|
||||
*/
|
||||
gdjs.RuntimeScene.prototype.createObject = function(objectName){
|
||||
|
||||
@@ -686,7 +687,7 @@ gdjs.RuntimeScene.prototype.createObject = function(objectName){
|
||||
|
||||
/**
|
||||
* Must be called whenever an object must be removed from the scene.
|
||||
* @param {gdjs.RuntimeObject} object The object to be removed.
|
||||
* @param {gdjs.RuntimeObject} obj The object to be removed.
|
||||
*/
|
||||
gdjs.RuntimeScene.prototype.markObjectForDeletion = function(obj) {
|
||||
//Add to the objects removed list.
|
||||
@@ -764,7 +765,7 @@ gdjs.RuntimeScene.prototype.getInitialSharedDataForBehavior = function(name) {
|
||||
/**
|
||||
* Set the data representing the initial shared data of the scene for the specified behavior.
|
||||
* @param {string} name The name of the behavior
|
||||
* @param {?BehaviorSharedData} behaviorSharedData The shared data for the behavior, or null to remove it.
|
||||
* @param {?BehaviorSharedData} sharedData The shared data for the behavior, or null to remove it.
|
||||
*/
|
||||
gdjs.RuntimeScene.prototype.setInitialSharedDataForBehavior = function(name, sharedData) {
|
||||
this._initialBehaviorSharedData.put(name, sharedData);
|
||||
@@ -792,7 +793,6 @@ gdjs.RuntimeScene.prototype.hasLayer = function(name) {
|
||||
|
||||
/**
|
||||
* Add a layer.
|
||||
* @param {string} name The name of the layer
|
||||
* @param {LayerData} layerData The data to construct the layer
|
||||
*/
|
||||
gdjs.RuntimeScene.prototype.addLayer = function(layerData) {
|
||||
@@ -912,7 +912,7 @@ gdjs.RuntimeScene.prototype.startProfiler = function(onProfilerStopped) {
|
||||
* Stop the profiler being run on the scene.
|
||||
*/
|
||||
gdjs.RuntimeScene.prototype.stopProfiler = function() {
|
||||
if (!this._profiler) return null;
|
||||
if (!this._profiler) return;
|
||||
|
||||
var oldProfiler = this._profiler;
|
||||
var onProfilerStopped = this._onProfilerStopped;
|
||||
|
@@ -7,6 +7,7 @@
|
||||
// Import all the types as global typedefs so that they can be used
|
||||
// in any JS file of the game engine/extensions/tests. This file is not read by JSDoc
|
||||
// because it's not compatible with these TypeScript definitions and import.
|
||||
|
||||
/**
|
||||
* @typedef { import("./project-data").ProjectData } ProjectData
|
||||
* @typedef { import("./project-data").ProjectPropertiesData } ProjectPropertiesData
|
||||
@@ -20,6 +21,8 @@
|
||||
* @typedef { import("./project-data").ResourceData } ResourceData
|
||||
* @typedef { import("./project-data").ResourcesData } ResourcesData
|
||||
* @typedef { import("./project-data").BehaviorSharedData } BehaviorSharedData
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef { import("pixi.js") } PIXI
|
||||
*/
|
||||
|
@@ -229,7 +229,6 @@ gdjs.WebsocketDebuggerClient.prototype.sendRuntimeGameDump = function () {
|
||||
|
||||
// Exclude some RuntimeScene fields:
|
||||
'_allInstancesList',
|
||||
'_initialObjectsData',
|
||||
|
||||
// Exclude circular references to parent runtimeGame or runtimeScene:
|
||||
'_runtimeGame',
|
||||
|
@@ -17,6 +17,7 @@
|
||||
"dependencies": {},
|
||||
"scripts": {
|
||||
"check-types": "tsc",
|
||||
"test": "cd tests && npm test",
|
||||
"generate-doc": "jsdoc -c docs/jsdoc.conf.json docs/DocMainPage.md"
|
||||
}
|
||||
}
|
||||
|
@@ -14,8 +14,15 @@ describe('gdjs.RuntimeScene integration tests', function () {
|
||||
});
|
||||
const runtimeScene = new gdjs.RuntimeScene(runtimeGame);
|
||||
runtimeScene.loadFromScene({
|
||||
layers: [{ name: '', visibility: true, effects: [] }],
|
||||
layers: [{ name: '', visibility: true, cameras: [], effects: [] }],
|
||||
variables: [],
|
||||
r: 0,
|
||||
v: 0,
|
||||
b: 0,
|
||||
mangledName: 'Scene1',
|
||||
name: 'Scene1',
|
||||
stopSoundsOnStartup: false,
|
||||
title: '',
|
||||
behaviorsSharedData: [],
|
||||
objects: [
|
||||
{
|
||||
@@ -24,14 +31,19 @@ describe('gdjs.RuntimeScene integration tests', function () {
|
||||
behaviors: [
|
||||
{
|
||||
type: 'TestBehavior::TestBehavior',
|
||||
name: "SomeBehavior"
|
||||
},
|
||||
],
|
||||
variables: [],
|
||||
},
|
||||
],
|
||||
instances: [],
|
||||
});
|
||||
|
||||
const object = runtimeScene.createObject('Object1');
|
||||
if (!object) {
|
||||
throw new Error("object should have been created");
|
||||
}
|
||||
|
||||
// Check that the behavior was properly created
|
||||
expect(object.getVariables().get('lastState').getAsString()).to.eql(
|
||||
@@ -45,6 +57,9 @@ describe('gdjs.RuntimeScene integration tests', function () {
|
||||
);
|
||||
|
||||
const object2 = runtimeScene.createObject('Object1');
|
||||
if (!object2) {
|
||||
throw new Error("object should have been created");
|
||||
}
|
||||
|
||||
// Check that the behaviors are properly destroyed
|
||||
runtimeScene.unloadScene();
|
||||
@@ -64,16 +79,24 @@ describe('gdjs.RuntimeScene integration tests', function () {
|
||||
const runtimeScene = new gdjs.RuntimeScene(runtimeGame);
|
||||
runtimeScene.loadFromScene({
|
||||
layers: [
|
||||
{ name: '', visibility: true, effects: [] },
|
||||
{ name: 'MyLayer', visibility: true, effects: [] },
|
||||
{ name: '', visibility: true, cameras: [], effects: [] },
|
||||
{ name: 'MyLayer', visibility: true, cameras: [], effects: [] },
|
||||
],
|
||||
variables: [],
|
||||
r: 0,
|
||||
v: 0,
|
||||
b: 0,
|
||||
mangledName: 'Scene1',
|
||||
name: 'Scene1',
|
||||
stopSoundsOnStartup: false,
|
||||
title: '',
|
||||
behaviorsSharedData: [],
|
||||
objects: [
|
||||
{
|
||||
type: 'Sprite',
|
||||
name: 'MyObject',
|
||||
behaviors: [],
|
||||
// @ts-ignore
|
||||
animations: [],
|
||||
updateIfNotVisible: false,
|
||||
},
|
||||
@@ -88,6 +111,9 @@ describe('gdjs.RuntimeScene integration tests', function () {
|
||||
const object1 = runtimeScene.createObject('MyObject');
|
||||
const object2 = runtimeScene.createObject('MyObject');
|
||||
const object3 = runtimeScene.createObject('MyObject');
|
||||
if (!object1 || !object2 || !object3) {
|
||||
throw new Error("object should have been created");
|
||||
}
|
||||
object2.setLayer('MyLayer');
|
||||
|
||||
runtimeScene.addLayer({
|
||||
|
@@ -1,5 +1,5 @@
|
||||
describe('gdjs.TimeManager', function() {
|
||||
var timeManager = new gdjs.TimeManager(0);
|
||||
var timeManager = new gdjs.TimeManager();
|
||||
|
||||
it('should handle timers', function(){
|
||||
timeManager.addTimer("timer1");
|
||||
|
Reference in New Issue
Block a user