mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-20 18:29:57 -04:00
Update sprite and clones to have basic costume support
This commit is contained in:
parent
29a595345a
commit
be06078df1
2 changed files with 54 additions and 10 deletions
src/sprites
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue