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

#1 2011-08-08 12:18:59

artentnu2009
Scratcher
Registered: 2009-09-25
Posts: 8

communication between sprites

Hi I have the following questions.
1) is t possible for a sprite to broadcast its position?
2) is it possible to dynamically create new sprite at run time?

thanks Letizia Jaccheri

Offline

 

#2 2011-08-08 12:35:48

Servine
Scratcher
Registered: 2011-03-19
Posts: 1000+

Re: communication between sprites

artentnu2009 wrote:

Hi I have the following questions.
1) is t possible for a sprite to broadcast its position?
2) is it possible to dynamically create new sprite at run time?

thanks Letizia Jaccheri

1) Yes.

<when green flag clicked>
<forever>
<set{ x }to( <x position>
<set{ y }to(  <y position>
<broadcast[ new position
<end>

<when I receive[ new position
<say[ <{ x }> ]for( 2 )secs>
<say[ <{ y }> ]for( 2 )secs>


http://bluetetrarpg.x10.mx/usercard/?name=Servine

Offline

 

#3 2011-08-08 14:47:48

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: communication between sprites

I'd say this belongs in All About Scratch. Remember that questions related to programming in Scratch go in All About Scratch, no matter how "advanced." I'll move it for you.  smile


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#4 2011-08-08 16:59:25

EdnaC
Scratcher
Registered: 2007-08-28
Posts: 100+

Re: communication between sprites

On dynamically creating a sprite - No.  If Servine's answer isn't what you're after (saying/thinking my position), you may want the functionality of the sensing block that has two pull-downs.  On the right, you pull down a list of all of the project's sprites, on the left, the list will have the position of that sprite, its direction, and its "for this sprite only" variables.  This lets other sprites detect position etc., of the sprite you're interested in.

Offline

 

#5 2011-08-08 17:08:28

Snowdrift
Scratcher
Registered: 2011-06-22
Posts: 500+

Re: communication between sprites

Servine wrote:

<when I receive[ new position
<say[ <{ x }> ]for( 2 )secs>
<say[ <{ y }> ]for( 2 )secs>

Acctually you could just do
<when I receive[ New Postion
<say[ <x position> ]for(2 )secs>
<say[ <y position> ]for(2 )secs>

Offline

 

#6 2011-08-08 19:31:24

ImagineIt
Scratcher
Registered: 2011-02-28
Posts: 1000+

Re: communication between sprites

Snowdrift wrote:

Servine wrote:

<when I receive[ new position
<say[ <{ x }> ]for( 2 )secs>
<say[ <{ y }> ]for( 2 )secs>

Acctually you could just do
<when I receive[ New Postion
<say[ <x position> ]for(2 )secs>
<say[ <y position> ]for(2 )secs>

I don't think he's trying to get the sprite to report it's own position.

Offline

 

Board footer