Update sprite and clones to have basic costume support

This commit is contained in:
Tim Mickel 2016-08-31 11:21:32 -04:00
parent 29a595345a
commit be06078df1
2 changed files with 54 additions and 10 deletions
src/sprites

View file

@ -7,12 +7,14 @@ var Blocks = require('../engine/blocks');
* @param {?Blocks} blocks Shared blocks object for all clones of sprite.
* @constructor
*/
function Sprite (blocks) {
function Sprite (blocks, name) {
if (!blocks) {
// Shared set of blocks for all clones.
blocks = new Blocks();
}
this.blocks = blocks;
this.name = name;
this.costumes = [];
this.clones = [];
}
@ -21,7 +23,7 @@ function Sprite (blocks) {
* @returns {!Clone} Newly created clone.
*/
Sprite.prototype.createClone = function () {
var newClone = new Clone(this.blocks);
var newClone = new Clone(this);
this.clones.push(newClone);
return newClone;
};