Tuesday 29 January 2019

Moving and detecting collisions

If you want to create games, or complex GUI, you can let the user move objects on your windows and detect collisions.
Just use the command "grab me" in the mouseDown object message:



on mouseDown
   grab me
end mouseDown

In order to detect collisions, just use the intersect() function, here it is a code and a video example:

on mouseDown
   grab me
end mouseDown

On Mousemove
   if intersect(image image1,image image2) then
      set the text of field field1 to "INTERSECTION"
      set the backgroundcolor of field field1 to 255,0,0
   else
      set the text of field field1 to "NOT INTERSECTION"
      set the backgroundcolor of field field1 to 0,255,0
   end if   
end Mousemove


No comments:

Post a Comment