Discuss Scratch

magnus04
Scratcher
5 posts

clones/sprites effeciency

so I was helping my son with a game where there would be lots of little aliens to shoot. and I was assuming that i would make everything by cloning but then if everything is a clone then i can only collision detect via touching color in a forever loop in each clone which not surprisingly grinds to a halt quickly.
It would seem i have to go through the tedium of creating them all as sprites. or all of the aliens anyway and then the “bullets” (or whatever they are) can be clones and detect a hit on a sprite. will that be faster?
scubajerry
Scratcher
1000+ posts

clones/sprites effeciency

That doesn't sound right. Can you share the project where that is happening?
magnus04
Scratcher
5 posts

clones/sprites effeciency

http://scratch.mit.edu/projects/13630916/

that's the link. or do we have to “share” it first? sorry, just jumping into this…
scubajerry
Scratcher
1000+ posts

clones/sprites effeciency

magnus04 wrote:

http://scratch.mit.edu/projects/13630916/

that's the link. or do we have to “share” it first? sorry, just jumping into this…
It has to be shared.
derniersamourai
Scratcher
100+ posts

clones/sprites effeciency

Not necessary to share.
When you use “Wait until <touching color …>” it is very cpu consuming!

Just replace that with a loop containing if <touching color …> then … and add before the “if” (still within the loop) a small “wait 0.2 secs”.
Everything should be ok.
magnus04
Scratcher
5 posts

clones/sprites effeciency

so apparently the issue is the broadcast/message. we were broadcasting a message to create the clone. but then subsequent broadcasts create a clone from each previously created clone. resulting in a nice little geometric progression. So the receiving message/clone creation is part of the clones that are created. This was not self evident. But in any case, the solution seems to be to just create the clone of sprite2, directly from within sprite1, instead of sending a message and having sprite2 clone itself.
scubajerry
Scratcher
1000+ posts

clones/sprites effeciency

Great - We would have never helped you find that without sharing.

Powered by DjangoBB