Page 1 of 1

Create a button that deletes objects when they touch it?

Posted: Fri Jun 19, 2015 8:33 am
by sinep
I'm trying to create a button that acts as a trash can of sorts.

The button will sit at the bottom of the screen and I would like it so any object that it slid into it will be deleted.

I'm not sure why it's so hard to find an example. Thanks for any help.

Re: Create a button that deletes objects when they touch it?

Posted: Fri Jun 19, 2015 4:37 pm
by jmburnod
Hi Sinep,

I dont know if that way is the best way but you can try it

object script obj you want delete :

Code: Select all

on mousedown
   grab me
end mousedown

on mouseUp
   deControlMU
end mouseUp
cd script :

Code: Select all

on deControlMU
   put the short id of the target into tTargetID
   if intersect(the target,btn "bPoubelle") then
      send "deleteMyObject tTargetID" to me in 10 milliseconds
   end if
end deControlMU

on deleteMyObject pID
   delete control id pID
end deleteMyObject
Best regards
Jean-Marc