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

#1 2011-05-31 17:50:36

epochal
New Scratcher
Registered: 2011-04-13
Posts: 4

touching sprites - restricting variable change

When a sprite touches another, I want a variable to go up in value by just one. However, because they’re still touching, the variable keeps going up after the initial contact. How can I stop the variable from accumulating value after the first contact? Thanks in advance.

Offline

 

#2 2011-05-31 17:56:04

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

Re: touching sprites - restricting variable change

Just tell it to wait until it's not touching the sprite any more before it adds another value, like this:

Code:

When green flag clicked
Forever
    If <touching sprite1>
        change variable by 1
        wait until <not <touching sprite1> >
   End If
End Forever

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

 

#3 2011-06-01 09:57:00

epochal
New Scratcher
Registered: 2011-04-13
Posts: 4

Re: touching sprites - restricting variable change

That worked like a charm, Harakou. I sure appreciate it!

Offline

 

#4 2011-06-02 17:30:35

paragonanimation
New Scratcher
Registered: 2011-06-02
Posts: 1

Re: touching sprites - restricting variable change

Hey I am making a scratch game... obviously.... but i need help with it! I want a sprite to be able to be clicked when 4 other sprites are touching a block. but they will not touch in a specific order. Is this possible using a variable count up until all 4 sprites are touching the block? Then what!?!?!  big_smile
Please Help!

Offline

 

#5 2011-06-02 17:50:49

Kileymeister
Scratcher
Registered: 2008-04-17
Posts: 1000+

Re: touching sprites - restricting variable change

paragonanimation wrote:

Hey I am making a scratch game... obviously.... but i need help with it! I want a sprite to be able to be clicked when 4 other sprites are touching a block. but they will not touch in a specific order. Is this possible using a variable count up until all 4 sprites are touching the block? Then what!?!?!  big_smile
Please Help!

Put this in the four sprites touching the block:
http://i54.tinypic.com/w6qtyt.gif

Put this in the sprite being clicked:
http://i56.tinypic.com/28utdtt.gif


I'm back, and showcasing two new* projects!  Click left or right on the image below to see!
http://img109.imageshack.us/img109/7905/part1l.pnghttp://img859.imageshack.us/img859/6417/part2bf.png

Offline

 

Board footer