Using Slide
The Slide command makes an object
move from one place to another.
If you click on the right penguin,
it will Slide up to the top. If you click
the fish, it will slide to meet the penguin.
The Slide command is written as:
Slide(id,startX,startY,endX,endY,time,1)
For example:
Slide(fish,50,300,500,120,1000,1)
- Practice -
0 -
Download
this .zip archive that contains
the web-page and the pictures
Start Komodo (or any other editor)
and open the web-page Sliding.html
1 - Change the Javascript so the fish starts
near the top of the page. It should
still
Slide correctly to meet the penguin.
2 - Move the clickable penguin picture
so it is on top of the original penguin.
It should still Slide correctly to the
top-right of the picture when clicked.
3 - Add two more pictures, maybe a
polar bear and a bigger fish (salmon).
Make them slide to the top-left of the
ice when clicked, meeting each other.
4 - Add another picture that starts at
the top of the ice and Slides straight
down to the bottom.
5 - Add more pictures for practice, as many
as you can during one class.
6 - Change the RESET function so that
it moves ALL pictures back to
their original positions.