More documentation in sprite, clone

This commit is contained in:
Tim Mickel 2016-07-06 14:09:06 -04:00
parent 2e01caa8a6
commit 7c24bdc612
2 changed files with 15 additions and 1 deletions

View file

@ -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;

View file

@ -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);