Page 1 of 1
Back To The Future with Drag-&-Drop
Posted: Fri Jun 07, 2024 9:51 am
by richmond62
Well, back to a Macintosh Performa 5200 in 1996 in Saudi Arabia and my 2 sons: 1 and 4 years old, and this:
-

- Sorting_Station.jpg (108.67 KiB) Viewed 7028 times
-
This was part of an Edmark CD-Rom called "Sammy's Science House":
-

- sammy.gif (32.23 KiB) Viewed 7017 times
-
https://en.wikipedia.org/wiki/Early_Learning_House
The idea behind this exercise was for small kids to drag beasties of various categories into various rubbish bins.
Mimicking this program is a wonderful way to get one's head round OXT's drag-&-drop capabilities.
Download the original here:
https://macintoshgarden.org/games/sammys-science-house
Re: Back To The Future with Drag-&-Drop
Posted: Fri Jun 07, 2024 10:08 am
by richmond62
So, let's start off with a stack with 2 rubbish bins and 6 beasties: 3 insects, and 3 non-insects:
-

- s1.png (108.25 KiB) Viewed 7024 times
-
Re: Back To The Future with Drag-&-Drop
Posted: Fri Jun 07, 2024 10:29 am
by richmond62
Before we get into drag-and-drop we need to set up a button to return the animal to where they started:
-

- s2.png (24.14 KiB) Viewed 7023 times
-

- s3.png (135.91 KiB) Viewed 7023 times
-
Re: Back To The Future with Drag-&-Drop
Posted: Fri Jun 07, 2024 10:37 am
by richmond62
So that we can move an image with the mouse we give it the following code:
-

- s4.png (40.16 KiB) Viewed 7022 times
-
We put the
grab me code inside a
mouseDown command so when we release the mouse the image stops moving.
Re: Back To The Future with Drag-&-Drop
Posted: Fri Jun 07, 2024 10:41 am
by richmond62
Now we have to make sure that when an image is dragged to the CORRECT rubbish bin it stays there, and when an image is dragged to the INCORRECT rubbish bin it is returned to its original location.
Here is the code for the 'ladybird':
-

- s5.png (71.09 KiB) Viewed 7021 times
-
Line 6 checks if the
ladybird overlaps the
rubbish bin for insects.
If this is true,
Line 7 makes the ladybird invisible.
Line 8 sends the ladybird back to its start position.
If this is not true,
Line 10 sends the ladybird back to its start position.
Obviously we now have to put extra code into the RESTART button so all the animals become visible again:
-

- s6.png (148.63 KiB) Viewed 7019 times
Re: Back To The Future with Drag-&-Drop
Posted: Fri Jun 07, 2024 10:59 am
by richmond62
I am uploading the stack at this stage so that YOU can complete the exercise by yourself.