Drag and Drop Objects - (Grab command) (drag-n-drop code) The Grab command (with a mouseDown) grabs and object and holds an object until the mouse button is released An example of its use is: Put 3 buttons on the right side of the screen and name them "red", "blue" and "green". Then make them each the color of their name. Put a button on the left side and name it "box", color it red and add the following code to it on mouseDown grab me end mouseDown on mouseUp if intersect(button "box",button "red") then answer "Good job!" end if if intersect(button "box",button "blue") then set loc of button "box" to 50,50 end if if intersect(button "box",button "green") then set loc of button "box" to 50,50 end if end mouseUp This technique is good for educational games (like match, etc) and games like Sheep Herder The Set Command Using the Set command, you can also do it this way by adding this code to the object that you want to move:
NEXT - Changing Properties in Code |
Home >