@@ -82,7 +82,7 @@ SpeechBubbleMorph, RingMorph, isNil, FileReader, TableDialogMorph,
8282BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, localize,
8383TableMorph, TableFrameMorph*/
8484
85- modules . objects = '2016-May-02 ' ;
85+ modules . objects = '2016-May-04 ' ;
8686
8787var SpriteMorph ;
8888var StageMorph ;
@@ -1364,7 +1364,7 @@ SpriteMorph.prototype.init = function (globals) {
13641364
13651365// SpriteMorph duplicating (fullCopy)
13661366
1367- SpriteMorph . prototype . fullCopy = function ( ) {
1367+ SpriteMorph . prototype . fullCopy = function ( forClone ) {
13681368 var c = SpriteMorph . uber . fullCopy . call ( this ) ,
13691369 myself = this ,
13701370 arr = [ ] ,
@@ -1374,20 +1374,22 @@ SpriteMorph.prototype.fullCopy = function () {
13741374 c . color = this . color . copy ( ) ;
13751375 c . blocksCache = { } ;
13761376 c . paletteCache = { } ;
1377- c . scripts = this . scripts . fullCopy ( ) ;
1377+ c . scripts = this . scripts . fullCopy ( forClone ) ;
13781378 c . scripts . owner = c ;
13791379 c . variables = this . variables . copy ( ) ;
13801380 c . variables . owner = c ;
13811381 c . customBlocks = [ ] ;
1382- this . customBlocks . forEach ( function ( def ) {
1383- cb = def . copyAndBindTo ( c ) ;
1384- c . customBlocks . push ( cb ) ;
1385- c . allBlockInstances ( def ) . forEach ( function ( block ) {
1386- block . definition = cb ;
1382+ if ( ! forClone ) {
1383+ this . customBlocks . forEach ( function ( def ) {
1384+ cb = def . copyAndBindTo ( c ) ;
1385+ c . customBlocks . push ( cb ) ;
1386+ c . allBlockInstances ( def ) . forEach ( function ( block ) {
1387+ block . definition = cb ;
1388+ } ) ;
13871389 } ) ;
1388- } ) ;
1390+ }
13891391 this . costumes . asArray ( ) . forEach ( function ( costume ) {
1390- var cst = costume . copy ( ) ;
1392+ var cst = forClone ? costume : costume . copy ( ) ;
13911393 arr . push ( cst ) ;
13921394 if ( costume === myself . costume ) {
13931395 c . costume = cst ;
@@ -1404,12 +1406,11 @@ SpriteMorph.prototype.fullCopy = function () {
14041406 c . anchor = null ;
14051407 c . parts = [ ] ;
14061408 this . parts . forEach ( function ( part ) {
1407- var dp = part . fullCopy ( ) ;
1409+ var dp = part . fullCopy ( forClone ) ;
14081410 dp . nestingScale = part . nestingScale ;
14091411 dp . rotatesWithAnchor = part . rotatesWithAnchor ;
14101412 c . attachPart ( dp ) ;
14111413 } ) ;
1412-
14131414 return c ;
14141415} ;
14151416
@@ -2834,12 +2835,30 @@ SpriteMorph.prototype.remove = function () {
28342835 }
28352836} ;
28362837
2837- // SpriteMorph cloning (experimental)
2838+ // SpriteMorph cloning
2839+
2840+ /*
2841+ clones are temporary, partially shallow copies of sprites that don't
2842+ appear as icons in the corral. Clones get deleted when the red stop button
2843+ is pressed. Shallow-copying clones' scripts and costumes makes spawning
2844+ very fast, so they can be used for particle system simulations.
2845+ This speed-up, however, comes at the cost of some detrimental side
2846+ effects: Changes to a costume or a script of the original sprite are
2847+ in some cases shared with all of its clones, however such shared changes
2848+ are hard to predict for users and not actively propagated, so they don't
2849+ offer any reliable feature, and will not be supported as such.
2850+ Changes to the original sprite's scripts affect all of its clones, unless
2851+ the script contains any custom block whose definition contains one or more
2852+ block variables (in which case the script does get deep-copied).
2853+ The original sprite's scripting area, costumes wardrobe or sounds jukebox
2854+ are also not shared. therefore adding or deleting a script, sound or
2855+ costume in the original sprite has no effect on any of its clones.
2856+ */
28382857
28392858SpriteMorph . prototype . createClone = function ( ) {
28402859 var stage = this . parentThatIsA ( StageMorph ) ;
2841- if ( stage && stage . cloneCount <= 1000 ) {
2842- this . fullCopy ( ) . clonify ( stage ) ;
2860+ if ( stage && stage . cloneCount <= 2000 ) {
2861+ this . fullCopy ( true ) . clonify ( stage ) ;
28432862 }
28442863} ;
28452864
@@ -6636,7 +6655,6 @@ Costume.prototype.copy = function () {
66366655 var canvas = newCanvas ( this . extent ( ) ) ,
66376656 cpy ,
66386657 ctx ;
6639-
66406658 ctx = canvas . getContext ( '2d' ) ;
66416659 ctx . drawImage ( this . contents , 0 , 0 ) ;
66426660 cpy = new Costume ( canvas , this . name ? copy ( this . name ) : null ) ;
0 commit comments