1

I'm trying to get an object (a bus) to animate along a predetermined path on the scroll event.

The idea is to have it working in a similar fashion to this site. Unfortunately the original work is difficult to reverse engineer, despite being unminified, as a lot of the variable names are only 1-2 characters long and I am no mathematician.

I have a very rough draught available here though as you will see there is something wrong with my rotation calculations taken from another question here. Also the bus doesn't move back to the correct starting position.

        // Work out the angle to rotate the bus to for the next point.
        // MATHS!! 
        var deltaY = toTop - top,
            deltaX = toLeft - left,
            angle = Math.atan2(deltaY, deltaX) * 180 / Math.PI;

I know the waypoints are off just now.

Cheers.

Community
  • 1
  • 1
James South
  • 8,803
  • 3
  • 53
  • 110
  • Something like GSAP might be helpful: http://www.greensock.com/gsap-js/ when paired with the Bezier path plugin: http://api.greensock.com/js/com/greensock/plugins/BezierPlugin.html – hamstu Jun 24 '13 at 16:28
  • Cheers, I'll check it out. – James South Jun 24 '13 at 16:32

0 Answers0