mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
More documentation in sprite, clone
This commit is contained in:
parent
2e01caa8a6
commit
7c24bdc612
2 changed files with 15 additions and 1 deletions
|
@ -2,6 +2,11 @@ var util = require('util');
|
||||||
var MathUtil = require('../util/math-util');
|
var MathUtil = require('../util/math-util');
|
||||||
var Target = require('../engine/target');
|
var Target = require('../engine/target');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clone (instance) of a sprite.
|
||||||
|
* @param {!Blocks} spriteBlocks Reference to the sprite's blocks.
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
function Clone(spriteBlocks) {
|
function Clone(spriteBlocks) {
|
||||||
Target.call(this, spriteBlocks);
|
Target.call(this, spriteBlocks);
|
||||||
this.drawableID = null;
|
this.drawableID = null;
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
var Clone = require('./clone');
|
var Clone = require('./clone');
|
||||||
var Blocks = require('../engine/blocks');
|
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) {
|
function Sprite (blocks) {
|
||||||
// Sprites have: shared blocks, shared costumes, shared variables, etc.
|
|
||||||
if (!blocks) {
|
if (!blocks) {
|
||||||
// Shared set of blocks for all clones.
|
// Shared set of blocks for all clones.
|
||||||
blocks = new Blocks();
|
blocks = new Blocks();
|
||||||
|
@ -11,6 +16,10 @@ function Sprite (blocks) {
|
||||||
this.clones = [];
|
this.clones = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a clone of this sprite.
|
||||||
|
* @returns {!Clone} Newly created clone.
|
||||||
|
*/
|
||||||
Sprite.prototype.createClone = function () {
|
Sprite.prototype.createClone = function () {
|
||||||
var newClone = new Clone(this.blocks);
|
var newClone = new Clone(this.blocks);
|
||||||
this.clones.push(newClone);
|
this.clones.push(newClone);
|
||||||
|
|
Loading…
Reference in a new issue