Page 1 of 1

test with different name

Posted: Thu Dec 10, 2015 9:39 pm
by problème
Hello

I have image "bird" and others image "branch1","branch2",... . When the bird jump, it stops falling when it touches the floor or a branch, How can i test if he touches a branch, i try to rename branch1,branch2, ... to branch but it's don't work

Code: Select all

command JumpDown
   if ( ( the bottom of image "bird" <>  the top  of image  "floor" )) then -- or (the bottom of image imageHéros <> the top of image "branch" )  ) then 
      set  the location of  image "bird" to (item 1 of the location of  image imageHéros, item 2 of the location of  image imageHéros + 30)
      send "JumpDown" to me in 75 milliseconds 
   end if 
end JumpDown


Re: test with different name

Posted: Thu Dec 10, 2015 9:46 pm
by Dixie
Read up on 'intersect' in the dictionary...

Re: test with different name

Posted: Sat Dec 12, 2015 2:55 pm
by Klaus
Monsieur problème knows about "intersect": http://forums.livecode.com/viewtopic.php?f=7&t=26008

But obviously not much about meaningful thread titles! :D

Re: test with different name

Posted: Sat Dec 12, 2015 4:35 pm
by dunbarx
Hi.

Do you mean that you do not know in advance which branch the bird will land on?

If so, you still need to test for "intersect", but you also need to test for each branch: (pseudo)

Code: Select all

move bird down
get the number of images
repeat for each image tImage in it
if intersect(bird,tImage)...
Craig