View Single Post
It's Tricky, but only the first time.
Old
MrMoke
Senior Member
 
MrMoke's Avatar
 
Status: Offline
Posts: 501
Join Date: Sep 2007
Location: Austin, Texas
Smile It's Tricky, but only the first time. - 04-12-2014, 06:50 PM

Ifs and Whiles require a Boolean response (true or false), so dragging in any logical test satisfies the start, even (1>1).
Dragging a numeric function like "distanceTo" into either side gives one numeric value, so A.distanceTo(B) > 1.
Use the down arrow on the opposite side, select math and change it to 1+1, so A.distanceTo(B) > ( 1 + 1).

Lastly, use the same technique to replace the ones with A.getWidth()/2 and B.getWidth()/2, so

while(A.distanceTo(B) > ( (A.getWidth()/2)+(B.getWidth()/2) )

Probably seems like a lot of work, but if you have a routine that's constantly checking one object's distance to a list or array of 20 others, it requires negligible additional coding. You just replace say "B" with a reference to a list item.
   
Reply With Quote