This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2007-05-25 11:16:01

mrexcessive
Scratcher
Registered: 2007-05-21
Posts: 5

Create new sprite Dynamically

It would be really great if some mechanism to enable one sprite to create a new instance of another sprite could be devised.

For example :
I want to have a music synth which animates the notes played when the program is used.
I don't know in advance how many notes I'm going to need.
It would be great if I could create them from a 'template' note sprite.


A related facility would be for a sprite to be able to delete itself, or be deleted by the sprite which created it ? (or the background script which created it).


A safety feature (to prevent loss of data by coding mistakes) would be to only allow dynamically created sprites to be destroyed dynamically.
Related to this perhaps all dynamic sprites would be destroyed automatically when a program stopped executing.


I realise there are 'far too many sprites created' type issues with this sort of thing.  But perhaps a limit per second on creates and/or an overall limit on the pool size of dynamic sprites would get help in that respect.


I'd appreciate your comments : thanks ;-)


MrEx

Offline

 

#2 2007-05-25 23:55:37

fandebiao
Scratcher
Registered: 2007-05-15
Posts: 25

Re: Create new sprite Dynamically

i agree

Offline

 

#3 2007-05-27 07:03:11

mres
Scratch Team
Registered: 2007-03-08
Posts: 48

Re: Create new sprite Dynamically

We included a "clone" block in an early prototype of Scratch, but we found that users often got into trouble by accidently creating many more sprites than they wanted/expected. There is no doubt that "clone" was very useful for certain types of projects, but it was too "dangerous", so we removed it. We plan to revisit this issue in the future. We would like to provide the power of dynamic creation or cloning, but we want to make sure to keep Scratch simple and understandable.

Mitch Resnick
MIT Scratch Team

Last edited by mres (2007-05-27 07:03:30)

Offline

 

#4 2007-05-27 11:39:03

Kaydoodle13
Scratcher
Registered: 2007-05-19
Posts: 25

Re: Create new sprite Dynamically

I wasn't sure what they were trying to say at first, but when the Scratch Team person said something, I understood. What if you could make the cloning device so that we choose how many of those we need.  roll
Oh, also, today I made a game and made many mistakes in the scripts. I had to have 28 sprites have the same script, I messed up twice! Uhhhhhhhhhh....  mad

Last edited by Kaydoodle13 (2007-05-27 11:39:51)


._.*._.*._.Kaydoodle13._.*._.*._.

Offline

 

#5 2007-05-27 19:52:18

jay
Scratch Team
Registered: 2007-03-11
Posts: 59

Re: Create new sprite Dynamically

Kaydoodle,
I have had that same problem many times. I learned a workaround for it which isn't perfect, but good enough. When I want to create 20 of the same sprite, I make one sprite the way I think it's supposed to be, then I save the project. After saving, I copy the sprite 19 times and see if it does what I want. If not, I don't save, I just open up the previous version. That way I don't have to cut all the sprites I have just copied. Then I make some changes to the first sprite again and repeat.

A Secret Trick
When I copy the same sprite 19 times in a row (or cut sprites a lot in a row) I hold down the "shift" button while copying (or cutting) the sprites. This way the pointer doesn't turn back to an arrow. It makes it go much faster.

Offline

 

#6 2007-05-28 00:53:29

bernatp
Scratcher
Registered: 2007-03-07
Posts: 49

Re: Create new sprite Dynamically

James wrote:

I hold down the "shift" button while copying (or cutting) the sprites. This way the pointer doesn't turn back to an arrow.

This is a cool trick. I don't know why you don't mention it in the reference guide(?).

Offline

 

#7 2007-05-29 18:18:18

tammy
Scratcher
Registered: 2007-03-07
Posts: 57

Re: Create new sprite Dynamically

We're planning to put together support materials with Scratch "tips and tricks" that are somewhat "hidden." 

Good suggestion to add it to the reference guide.  Maybe we will consider it in the future (keeping in mind that we don't want the reference guide to get too long or too detailed).

Thanks!

Offline

 

#8 2007-06-07 18:58:33

SeanMcTex
Scratcher
Registered: 2007-05-27
Posts: 1

Re: Create new sprite Dynamically

I'd love to see dynamically instantiated instances of sprites too! I've had several cases already where I've been designing along in my head and come up suddenly against that lack.

Offline

 

#9 2007-06-07 20:11:32

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: Create new sprite Dynamically

If you don't want the reference guide to be long and detailed, don't hide tricks like shift-extras and shift-copy.  Make all the operations visible (as much as that contravenes hacker ethos, it is the only way to go for simple user interfaces).

Offline

 

#10 2007-06-08 14:13:08

jimmit
Scratcher
Registered: 2007-06-08
Posts: 2

Re: Create new sprite Dynamically

I agree the dynamic creation of sprites would be very useful.  Perhaps you can have a group of blocks under an 'advanced' group that could be turned on or off in the settings.  Other things like arrays could be useful.  It would also be nice to be able to set variables for these dynamic sprites when they are created or be able to access variables of other sprites.

Offline

 

#11 2007-06-13 15:34:53

MartinWollenweber
Scratcher
Registered: 2007-04-10
Posts: 100+

Re: Create new sprite Dynamically

I'm very happy that Mitch says the SCRATCH-Team wants to revisit the issue of a clone-block in the future:
GOOD REASONS FOR CLONE-ABILITY:
1. It's a realy a great waste of time to delete and recopy all equal Sprites manualy after a small change. Even If you use Jay's tricks it's still demotivating to do it again an again and causes often errors.
2. Missing of clone-ability weakens the explorative character of SCRATCH (you don't try a small change, cause it's to much work).
3. Also "cloning" as a programming-language feature is helpful to understand concepts of OO-Languages (it’s not as complex as the class/instance- or inheritance-concept, but it’s a start for beginners)
4. There are lots of projects with "manual" Sprite-clones. It seems to be an essential SCRATCH concept. I got no project without it.

SUGGESTION OF IMPLEMENTATION
To avoid the problem Mitch explained, the clone-Block could have a property that limits its number of clones to a certain amount (with a preset and a fixed maximum). To inspect the running clone-Sprites, they could apear like normal Sprites in the Sprite-pane (with a marker "I'm clone No.x of...") and vanish when the program stops (or even befor it starts next time). Clicking in the script-pain of clone-sprite could be redirected to the origin-Sprites script.
1. That doesn't seem to be to complicated to implement.
2. Even SCRATCH-Starters could understand that clone-concept and errors could be avoided.
3. Finaly it would save lots of boring work for every SCRATCHer.

What do you think?


Martin
...mitmachen beim  DACH-Scratch-Wiki und Scratch-Wiki-Autor werden!

Offline

 

#12 2007-06-13 20:34:13

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: Create new sprite Dynamically

Clones may need to have access to something to distinguish them from each other.
A serial number would be good, because then you could direct messages to specific sprites by using a global variable <sprite_to_respond>:

when I receive <foo>
if <serial_number> = <sprite_to_respond>
   say "Hey this one's for me!"

Offline

 

#13 2007-06-14 19:07:01

mungojelly
Scratcher
Registered: 2007-05-19
Posts: 35

Re: Create new sprite Dynamically

Of course in Squeak, the mother of Scratch, you can clone things programmatically all you want.  Squeak is much like Scratch except that it also has every advanced feature anyone here has requested-- and more.  In Squeak you can go through closing each sprite by hand like in Scratch easily enough, but earlier today when I needed to close 500 sprites I just said a mouthful of code at them and they went away.

This is an unpaid unsolicited endorsement!  I just think that people who are involved with Scratch ought to also understand what Squeak is, what the relationship & differences are.  Squeak has been trying and failing forever to be a ladder with which you can easily climb into programming.  Scratch is a much stronger, clearer, more graspable version of the first rung (or first few rungs) of that ladder.  In Squeak that rung is weaker, and the whole thing is weak and broken and nine-tenths missing, which makes sense if you consider it's the work of a few people trying to do what ought to be the great collective work of our whole civilization-- but it's there.

And of course it could become what it imagines itself to be, if enough people imagined with it.

<3

Offline

 

#14 2007-06-15 21:20:33

boinoinoi
Scratcher
Registered: 2007-06-05
Posts: 500+

Re: Create new sprite Dynamically

... this is funny to me because I have a game with one sprite cloned 200 times...

Last edited by boinoinoi (2007-06-16 08:15:25)


http://i30.tinypic.com/335fpxx.jpg
"Boinoinoi is the only person on the forums that I expect to be wearing a monocle all the time behind that screen, so I'm sure being as classy as he is, he knows what he's doing"        http://myfastcounter.com/count.php?c_style=88&amp;id=1284259111http://myfastcounter.com/count.php?c_style=88&amp;id=1286068127

Offline

 

#15 2007-06-17 16:49:42

Dragon_MC_
Scratcher
Registered: 2007-06-01
Posts: 1

Re: Create new sprite Dynamically

I totally agree. It would be useful in a shoot-em-up game when you can create multiple instances of a bullet, instead of having only one bullet that needs to collide with something before it can be used again.

Offline

 

#16 2007-09-05 04:40:36

hoshantm
Scratcher
Registered: 2007-09-05
Posts: 6

Re: Create new sprite Dynamically

I think that the ability to clone a sprite is really needed. A safety feature would be to default the maximum number of clones that can be created to a small number (10 for example). The programmer would have to explicitly bump this number. That could constitute a safety barrier that would prevent accidentally large number of sprites to be cloned. For each sprite, a variable could be provided by the system to query how many clones have been created for this particular sprite.

Offline

 

#17 2010-04-23 16:41:18

scriptmaven
Scratcher
Registered: 2009-11-20
Posts: 10

Re: Create new sprite Dynamically

tammy wrote:

We're planning to put together support materials with Scratch "tips and tricks" that are somewhat "hidden." 

Good suggestion to add it to the reference guide.  Maybe we will consider it in the future (keeping in mind that we don't want the reference guide to get too long or too detailed).

Thanks!

That would be nice.

Offline

 

#18 2010-06-13 13:50:40

hoshantm
Scratcher
Registered: 2007-09-05
Posts: 6

Re: Create new sprite Dynamically

mres wrote:

We included a "clone" block in an early prototype of Scratch, but we found that users often got into trouble by accidently creating many more sprites than they wanted/expected.

We could have a global setting that would limit the number of clones. This would be a safety net that could be removed through the settings menu. Being able to clone is one of the main features of OOP, the original sprite being at the same time the class and an instantiated object. That reminds me of VB6 form objects :-)

Offline

 

#19 2011-03-21 10:07:37

2pacfarrar
New Scratcher
Registered: 2011-03-21
Posts: 1

Re: Create new sprite Dynamically

2pacfarrar

when green flag clickedman <x position> right <point in direction( <point in direction( north west)<go to x:(25: 2)<  )y sad   <set pen color to( black) ><stop script>

Offline

 

#20 2011-03-21 10:57:10

throughthefire
Scratcher
Registered: 2009-07-09
Posts: 1000+

Re: Create new sprite Dynamically

mres wrote:

We included a "clone" block in an early prototype of Scratch, but we found that users often got into trouble by accidently creating many more sprites than they wanted/expected. There is no doubt that "clone" was very useful for certain types of projects, but it was too "dangerous", so we removed it. We plan to revisit this issue in the future. We would like to provide the power of dynamic creation or cloning, but we want to make sure to keep Scratch simple and understandable.

Mitch Resnick
MIT Scratch Team

Maybe you could make it like flash, with a central library of sprites and sounds and stuff, and there could be instances which you could create through scripts in the main sprite or you could program instances separately instead. Also, the library idea would make the file size smaller, as in flash!


Back. For now. Maybe.

Offline

 

#21 2011-04-30 22:50:14

scaterboy22
New Scratcher
Registered: 2011-04-30
Posts: 1

Re: Create new sprite Dynamically

<move(10  )steps><play sound[1  ]and waits>

Offline

 

#22 2011-12-25 04:20:30

namsan
New Scratcher
Registered: 2011-12-16
Posts: 1

Re: Create new sprite Dynamically

For clones the easy way BYOB a unofficial modification of scratch would be better. The problem is
1. you cannot share it in the web
2. you cannot use pre-made scratch sprites
3. you cannot open scratch files with BYOB
Some plus points are..
1. You can save it as a .exe file (.app for mac)
2 you can group a lot of blocks and then fuse them as one (for repetitive use of the same block )(also like a variable )

Offline

 

#23 2011-12-25 08:34:43

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: Create new sprite Dynamically

namsan wrote:

For clones the easy way BYOB a unofficial modification of scratch would be better. The problem is
1. you cannot share it in the web
2. you cannot use pre-made scratch sprites
3. you cannot open scratch files with BYOB
Some plus points are..
1. You can save it as a .exe file (.app for mac)
2 you can group a lot of blocks and then fuse them as one (for repetitive use of the same block )(also like a variable )

Please don't necropost, this topic had been inactive since April.


Why

Offline

 

#24 2012-12-03 17:30:47

LFATCGS
New Scratcher
Registered: 2012-12-03
Posts: 1

Re: Create new sprite Dynamically

The ability to create new instances dynamically is still required.
I do not believe this feature would make it more difficult to understand Scratch, in fact, I think it would make many applications (shooters, simulations, games, etc) much easier. In addition, Scratch could then be used to teach object oriented programming. As MrExcessive originally said, a limit could be imposed to ensure that too many sprites are not generated. Come on guys, this would be great. You can do it!

As for 'necroposting', I make no apology - The Scratch team deserves to know that this feature is wanted by many.

Offline

 

#25 2012-12-03 17:33:54

jvvg
Scratcher
Registered: 2008-03-26
Posts: 1000+

Re: Create new sprite Dynamically

LFATCGS wrote:

The ability to create new instances dynamically is still required.
I do not believe this feature would make it more difficult to understand Scratch, in fact, I think it would make many applications (shooters, simulations, games, etc) much easier. In addition, Scratch could then be used to teach object oriented programming. As MrExcessive originally said, a limit could be imposed to ensure that too many sprites are not generated. Come on guys, this would be great. You can do it!

As for 'necroposting', I make no apology - The Scratch team deserves to know that this feature is wanted by many.

Please search more recent threads before bumping ones from a year ago. If you do a bit of searching, the clone block is coming into 2.0.

Last edited by jvvg (2012-12-03 17:36:59)


http://tiny.cc/zwgbewhttp://tiny.cc/e1gbewhttp://tiny.cc/zygbewhttp://tiny.cc/izgbew
Goodbye, Scratch 1.4  sad                                                        Hello Scratch 2.0!  smile

Offline

 

Board footer