From 7c24bdc612ffca680b2595104d28a75665227a10 Mon Sep 17 00:00:00 2001 From: Tim Mickel Date: Wed, 6 Jul 2016 14:09:06 -0400 Subject: [PATCH] More documentation in sprite, clone --- src/sprites/clone.js | 5 +++++ src/sprites/sprite.js | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/sprites/clone.js b/src/sprites/clone.js index ce64fda52..169d72cc7 100644 --- a/src/sprites/clone.js +++ b/src/sprites/clone.js @@ -2,6 +2,11 @@ var util = require('util'); var MathUtil = require('../util/math-util'); var Target = require('../engine/target'); +/** + * Clone (instance) of a sprite. + * @param {!Blocks} spriteBlocks Reference to the sprite's blocks. + * @constructor + */ function Clone(spriteBlocks) { Target.call(this, spriteBlocks); this.drawableID = null; diff --git a/src/sprites/sprite.js b/src/sprites/sprite.js index 1ec25b3ba..b4abdbbb5 100644 --- a/src/sprites/sprite.js +++ b/src/sprites/sprite.js @@ -1,8 +1,13 @@ var Clone = require('./clone'); var Blocks = require('../engine/blocks'); +/** + * Sprite to be used on the Scratch stage. + * All clones of a sprite have shared blocks, shared costumes, shared variables. + * @param {?Blocks} blocks Shared blocks object for all clones of sprite. + * @constructor + */ function Sprite (blocks) { - // Sprites have: shared blocks, shared costumes, shared variables, etc. if (!blocks) { // Shared set of blocks for all clones. blocks = new Blocks(); @@ -11,6 +16,10 @@ function Sprite (blocks) { this.clones = []; } +/** + * Create a clone of this sprite. + * @returns {!Clone} Newly created clone. + */ Sprite.prototype.createClone = function () { var newClone = new Clone(this.blocks); this.clones.push(newClone);