mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-10 21:39:57 -04:00
Clean up and add documentation to sprite/clone
This commit is contained in:
parent
2da121d019
commit
8339e2769f
2 changed files with 24 additions and 4 deletions
|
@ -205,7 +205,7 @@ Clone.prototype.setCostume = function (index) {
|
||||||
this.currentCostume = index;
|
this.currentCostume = index;
|
||||||
if (this.renderer) {
|
if (this.renderer) {
|
||||||
this.renderer.updateDrawableProperties(this.drawableID, {
|
this.renderer.updateDrawableProperties(this.drawableID, {
|
||||||
skin: this.sprite.costumes[this.currentCostume].baseLayerMD5
|
skin: this.sprite.costumes[this.currentCostume].skin
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -221,7 +221,7 @@ Clone.prototype.updateAllDrawableProperties = function () {
|
||||||
direction: this.direction,
|
direction: this.direction,
|
||||||
scale: [this.size, this.size],
|
scale: [this.size, this.size],
|
||||||
visible: this.visible,
|
visible: this.visible,
|
||||||
skin: this.sprite.costumes[this.currentCostume].baseLayerMD5
|
skin: this.sprite.costumes[this.currentCostume].skin
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,14 +7,34 @@ var Blocks = require('../engine/blocks');
|
||||||
* @param {?Blocks} blocks Shared blocks object for all clones of sprite.
|
* @param {?Blocks} blocks Shared blocks object for all clones of sprite.
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function Sprite (blocks, name) {
|
function Sprite (blocks) {
|
||||||
if (!blocks) {
|
if (!blocks) {
|
||||||
// Shared set of blocks for all clones.
|
// Shared set of blocks for all clones.
|
||||||
blocks = new Blocks();
|
blocks = new Blocks();
|
||||||
}
|
}
|
||||||
this.blocks = blocks;
|
this.blocks = blocks;
|
||||||
this.name = name;
|
/**
|
||||||
|
* Human-readable name for this sprite (and all clones).
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
this.name = '';
|
||||||
|
/**
|
||||||
|
* List of costumes for this sprite.
|
||||||
|
* Each entry is an object, e.g.,
|
||||||
|
* {
|
||||||
|
* skin: "costume.svg",
|
||||||
|
* name: "Costume Name",
|
||||||
|
* bitmapResolution: 2,
|
||||||
|
* rotationCenterX: 0,
|
||||||
|
* rotationCenterY: 0
|
||||||
|
* }
|
||||||
|
* @type {Array.<!Object>}
|
||||||
|
*/
|
||||||
this.costumes = [];
|
this.costumes = [];
|
||||||
|
/**
|
||||||
|
* List of clones for this sprite, including the original.
|
||||||
|
* @type {Array.<!Clone>}
|
||||||
|
*/
|
||||||
this.clones = [];
|
this.clones = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue