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

#1 2013-02-25 18:10:56

Photoguy77
New Scratcher
Registered: 2013-02-16
Posts: 9

Help!!!!!!!!!!

I want to have it so that when a sprite is close to another sprite a variable changes. How do I do this??

Offline

 

#2 2013-02-25 18:14:57

FeatherWind
Scratcher
Registered: 2012-10-24
Posts: 100+

Re: Help!!!!!!!!!!

when gf clicked
If <distance to sprite>=<distance>
Change(variable) by [whatever]
end

Last edited by FeatherWind (2013-02-25 18:15:23)


http://stream1.gifsoup.com/view/37620/shugo-chara-amu-o.gif [url=http://gifsoup.com/view/37620/shugo-chara-amu.html]

Offline

 

#3 2013-02-25 18:42:16

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

Re: Help!!!!!!!!!!

You could also use less than to do that, because the distance might change to fast for the equals operator...


Hope that helps,

CAA14

Offline

 

#4 2013-02-25 19:43:35

Photoguy77
New Scratcher
Registered: 2013-02-16
Posts: 9

Re: Help!!!!!!!!!!

How about this??

       

       when gf clicked
       forever
         if < (distance to CutieCake v) = (15 pixels) >
            change Yellow Ball Points v by 1
        

Offline

 

#5 2013-02-25 19:51:44

Photoguy77
New Scratcher
Registered: 2013-02-16
Posts: 9

Re: Help!!!!!!!!!!

I meant:

     

      When gf Clicked
      forever
        if <(distance to CutieCake v) = (15 pixels)
         change (Yellow Ball Points v) by (1)
      

Offline

 

#6 2013-02-25 19:59:40

Photoguy77
New Scratcher
Registered: 2013-02-16
Posts: 9

Re: Help!!!!!!!!!!

Ohhhhhhhhhh... look at this for the if:

       

       
       if<(distance to CutieCakev)=(15 pixels)
       
       

Offline

 

#7 2013-02-25 20:09:05

FeatherWind
Scratcher
Registered: 2012-10-24
Posts: 100+

Re: Help!!!!!!!!!!

yep, that would work.


http://stream1.gifsoup.com/view/37620/shugo-chara-amu-o.gif [url=http://gifsoup.com/view/37620/shugo-chara-amu.html]

Offline

 

#8 2013-02-25 20:58:39

kayybee
Scratcher
Registered: 2009-12-07
Posts: 1000+

Re: Help!!!!!!!!!!

No, you would want to use a < operator as distance usually isn't a whole number.

Offline

 

#9 2013-02-26 12:55:22

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

Re: Help!!!!!!!!!!

kayybee wrote:

No, you would want to use a < operator as distance usually isn't a whole number.

Exactly. I had a similar problem with one of my projects, i wanted certain sprites to disappear when their x coordinate equaled -270 x, but i was moving the sprites by -5, and they never got to exactly -270. To fix it, i had to change the "=" sign to "<" sign.

Hope that helps,

CAA14

Offline

 

#10 2013-02-26 13:02:03

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

Re: Help!!!!!!!!!!

Photoguy77 wrote:

I meant:

     

      When gf Clicked
      forever
        if < (distance to CutieCake) = [15] >
         change [Yellow Ball Points v] by (1)
      

Fixed.

Just curious, who is "cutiecake"?

Regards,

CAA14

Offline

 

Board footer