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

#1 2012-07-16 11:44:39

berberberber
Scratcher
Registered: 2012-03-08
Posts: 1000+

Duplicate if blocks

When I view some advanced scratchers project's, they have if blocks with the same boolean statement in them.  AgentRoop did this:

if <touching color [#000000]?>
change y by ([abs v] of (xvel))
 if <touching color [#000000]?>
 change y by (([abs v] of (xvel)) * (-1))
 end
end
What does having multiple if blocks do?  Wouldn't they cancel each other out?


http://i47.tinypic.com/2iaa73k.png

Offline

 

#2 2012-07-16 11:59:04

TRocket
Scratcher
Registered: 2009-08-18
Posts: 1000+

Re: Duplicate if blocks

in that example, since there's a change y by() block the sprite may not be touching that color anymore. Therefore the second if is more like if still touching color(BLACK)


http://i.imgur.com/1QqnHxQ.png

Offline

 

#3 2012-07-16 12:01:52

Wes64
Scratcher
Registered: 2011-08-19
Posts: 1000+

Re: Duplicate if blocks

Basically its in the proper order to cancel itself.
So if it is touching black on the FIRST if block and then it moves, it might not be touching black any more.


Experienced 2.0 Tester: Ask me questions!
Using Firefox 13.0, Flash plugin version 11.4.402.287, and Windows XP Professional.

Offline

 

Board footer