* Provide property to Clone to distinguish "original" clones

* Provide method to clone a clone's properties

* Don't report clones in the UI target list

* Add target info to Thread

* Allow hats to skip clones (for green flag)

* Green flag skips clones

* Implement "create clone" and hat

* Pass the runtime to sprites and clones (for start hats)

* Clone disposal; trigger hats after drawable initializes.

* Separate stop threads for target; fix handling of stop button

* Remove extraneous `skipClones` property

* Add global clone limit

* Don't allow a non-clone to delete itself.

* Rename `cloneClone` -> `makeClone`

* Variable updates in runtime.js

* Synchronous drawable initialization (until we put it back to promises)
This commit is contained in:
Tim Mickel 2016-09-15 19:37:12 -04:00 committed by GitHub
parent 542899949e
commit 9744bcbb70
10 changed files with 229 additions and 37 deletions
src/sprites

View file

@ -5,9 +5,11 @@ 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.
* @param {Runtime} runtime Reference to the runtime.
* @constructor
*/
function Sprite (blocks) {
function Sprite (blocks, runtime) {
this.runtime = runtime;
if (!blocks) {
// Shared set of blocks for all clones.
blocks = new Blocks();
@ -43,8 +45,13 @@ function Sprite (blocks) {
* @returns {!Clone} Newly created clone.
*/
Sprite.prototype.createClone = function () {
var newClone = new Clone(this);
var newClone = new Clone(this, this.runtime);
newClone.isOriginal = this.clones.length == 0;
this.clones.push(newClone);
if (newClone.isOriginal) {
newClone.initDrawable();
newClone.updateAllDrawableProperties();
}
return newClone;
};