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

#1 2010-05-30 08:05:55

DB88
Scratcher
Registered: 2010-05-20
Posts: 42

Need "Next Sprite" and "Sprite #"

I have a project where I have to constantly check for a collision between sprite 1 and 55 other sprites.  The code would be MUCH simpler and shorter if instead of 55 IF blocks to check for each sprite, I could have just one if block and repeat it while incrementing through the sprites in order.  Adding "Next Sprite" and "Sprite #" blocks would allow for this.  Think of it as what "Next Costume" and "Costume #" do on a local level for a single sprite, "Next Sprite" and "Sprite #" would do on a global level.


Most Recent Projects: 
Four Bar Linkage Animator:  http://scratch.mit.edu/projects/DB88/1102417  ...... Moon Defender:  http://scratch.mit.edu/projects/DB88/1092234  ..... BUGS:  http://scratch.mit.edu/projects/DB88/1095318

Offline

 

#2 2010-05-30 08:43:02

climber59
Scratcher
Registered: 2009-12-15
Posts: 100+

Re: Need "Next Sprite" and "Sprite #"

Just name all the sprites xxxxx1, xxxxx2... Then put a variable in the <touching[]?> block.

Last edited by climber59 (2010-05-30 08:43:13)


Check out my projects if you have a chance.

Offline

 

#3 2010-05-30 09:35:15

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Need "Next Sprite" and "Sprite #"

I see what you mean - it would be a whole lot easier to just put in a few blocks instead of 55. Unfortunately, I feel this may take away from the simplicity of the program, which is what the program is all about.

Offline

 

#4 2010-05-30 09:46:07

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Need "Next Sprite" and "Sprite #"

Actually, you can already shorten your script quite a bit by making a list with all of the sprites you want the sprite to collide with, then using these blocks for the collision script:

Code:

<touching (item (any) of [collistionList])>

It should work perfectly, and reduce the need for huge numbers of <touching ...> blocks  big_smile

Offline

 

#5 2010-05-30 17:22:20

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: Need "Next Sprite" and "Sprite #"

A (sprite name) reporter would be nice, then you wouldn't have to manually insert sprite names into a list.


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

Board footer