Pixi.js: how is scrolling done on flashvhtml.com?

How is page scrolling created on flashvhtml.com ? How is scrolling triggered by the links at the top, and how are the other "below animation" events related to the scrolling background?

+3


source to share


2 answers


This is what I was able to put together:

  • Listeners for interaction are added to the file Trackpad.js

    . Listeners for events such as mouse drag, keyboard events, touch, etc. All of which evaluate to a variable value

    .
  • This variable is value

    Trackpad.js

    then used to set the position camera

    in the update

    main.js

    file method .
  • There are 3 main types that are displayed, if I understand it correctly: ScrollView

    , ScaleView

    , RocketView

    . All of those are initiated inside the method init

    main.js

    . But they are all defined in the file fvh.js

    .
  • Each of these three views has an updatePosition

    acceptor camera.y

    or mainScrollPosition

    as a parameter. These methods updatePosition

    are called inside the same file update

    method main.js

    .
  • Then there is ScrollMap.js

    one that contains loads of position data for all 3 views, for example. it contains data ScrollView

    in the format: mcxxx:{view:'nameofelement',depth:xx,startFrame:xxx,endFrame:xxx,position:[xxx,...]}

    etc.

  • There is also a variable sectionLandPositions

    defined in the file main.js

    , which is also very interesting because this is what is then used inside a method onMenuItemPressed

    in the same file for the tween and brings a specific section into view.

  • So the magic mostly happens in the methods updatePosition

    for each view and how the value is calculated in Trackpad.js

    . And here I leave you to further debug and take it home. :)

Under the control files: Trackpad.js

, fvh.js

, ScrollMap.js

, main.js

. I hope you find all of this useful.



PS Kudos to Waste-Creative for creating this informative and engaging website.

T

+6


source


An easy way to do this is by adding tweens and then using the scroll / drag tab and links to move around the timeline.

  • Tween one: Couples Camera slowly down.
  • Tween two: Wait for x, sprite in unset state y disappears, sprites disappear, ..


Make sure you don't play animations after creating them, but adjust the timing manually (depending on the scroll position).

There are several tweeing schemes you can use for pixi: Greensocks , Impact , tween.js And there was a discussion on the html5gamedevs forum .

+1


source







All Articles