You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* @param {pc.Application} [app] Optional application handler, to choose which pc.ScriptRegistry to add a script to.
267
266
* By default it will use `pc.Application.getApplication()` to get current pc.Application.
268
-
* @returns {function} So called Script Type, that developer is meant to extend by adding attributes and prototype methods.
267
+
* @returns {ScriptType} Function so called {@link ScriptType}, that developer is meant to extend by adding attributes and prototype methods.
268
+
* @example
269
+
* var Turning = pc.CreateScript('turn');
270
+
*
271
+
* // define `speed` attribute that is available in Editor UI
272
+
* Turning.attributes.add('speed', {
273
+
* type: 'number',
274
+
* default: 180,
275
+
* placeholder: 'deg/s'
276
+
* });
277
+
*
278
+
* // runs every tick
279
+
* Turning.prototype.update = function(dt) {
280
+
* this.entity.rotate(0, this.speed * dt, 0);
281
+
* };
269
282
*/
270
283
varCreateScript=function(name,app){
271
284
if(CreateScript.reservedScripts[name])
272
285
thrownewError('script name: \''+name+'\' is reserved, please change script name');
273
286
274
287
/**
275
288
* @name ScriptType
276
-
* @classClass(function) that is returned by {@link pc.CreateScript}. Also referred as Script Type.<br />
289
+
* @classFunction that is returned by {@link pc.CreateScript}. Also referred as Script Type.<br />
277
290
* This function is expected to be extended using JavaScript prototype. There is a <strong>list of expected methods</strong>
278
291
* that will be executed by the engine, such as: initialize, postInitialize, update, postUpdate and swap.<br />
279
292
* <strong>initialize</strong> and <strong>postInitialize</strong> - are called if defined when script is about to run for the first time. postInitialize will run after all initialize methods are executed in the same tick or enabling chain of actions.<br />
@@ -355,7 +368,7 @@ pc.extend(pc, function () {
355
368
* @function
356
369
* @name ScriptType#extend
357
370
* @param {Object} methods Object with methods, where key - is name of method, and value - is function.
358
-
* @description Shorthand function to extend Script Tyoe prototype with list of methods.
371
+
* @description Shorthand function to extend Script Type prototype with list of methods.
359
372
* @example
360
373
* var PlayerController = pc.CreateScript('playerController');
0 commit comments