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

#1 2012-09-28 00:18:54

brandon236
New Scratcher
Registered: 2012-09-19
Posts: 5

How do I make an object that stops my character when I touch it

I want an object (like a block) that when you touch it you just stop moving. But I also want it that if you touch it from the right then if you touch the left arrow key then you move to the left. I tried a script that said if it's touching the block then stop moving but I want it so that if its touching it on the right then you just stop moving right. Is there any script that can do that?

Offline

 

#2 2012-09-28 01:03:14

destructo-serpent
Scratcher
Registered: 2012-07-25
Posts: 1000+

Re: How do I make an object that stops my character when I touch it

i will answer the second part, this may not work

when gf clicked
forever
if <(distance to [mouse-pointer v]) = [1]>
point in direction (90 v)
change x by [-5] //increase for more speed. 
end
if <(distance to [mouse-pointer v]) = [-1]>
point in direction (-90 v)
change x by [-5] 

Offline

 

#3 2012-09-28 03:25:08

Jem12
Scratcher
Registered: 2012-04-20
Posts: 100+

Re: How do I make an object that stops my character when I touch it

one of my projects has this but i cant remember which one... look at my games and if one of them has what your looking for in it download it and look at the scripts.  tongue


"In the begging the universe was created, this made a lot of people angry and was widly regarded as a bad move" ~  Douglas Adams ~ The resturant at the end of the universe

Offline

 

#4 2012-09-28 08:01:08

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: How do I make an object that stops my character when I touch it

when gf clicked
forever
if<key [right arrow v] pressed?>
change x by (3)
if<touching [block v]?>
change x by (-3)
end
end
if<key [left arrow v] pressed?>
change x by (-3)
if<touching [block v]?>
change x by (3)
end
end
That will work in presentation mode (edit: and also online).  Edit mode would prefer this:

when gf clicked
forever
if<key [right arrow v] pressed?>
change x by (3)
if<touching [block v]?>
change x by (-3)
wait until <key [left arrow v] pressed?>
end
end
if<key [left arrow v] pressed?>
change x by (-3)
if<touching [block v]?>
change x by (3)
wait until <key [right arrow v] pressed?>
end
end

Last edited by MoreGamesNow (2012-09-28 08:01:51)


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

Board footer