I'm trying to figure out what is the best way to begin creating an effect like (https://howifight.53.com) where the background is scrollable/draggable in all directions.
I know the technology behind this is pixi.js however, I can't seem to dig out how this effect is achieved. Any pointers in a good direction would be awesome.
答案 0 :(得分:0)
First, you need to set up the page and styles.
You need a containing element to contain the HTML you're moving around (using overflow:hidden
). Then you need an element within that to actually move around with JavaScript.
Then you need to implement some drag/drop functionality. Capture mousedown
, then capture mousemove
and update on each requestAnimationFrame
, then stop dragging with mouseup
is triggered.
That's a very basic overview, but I've mocked up an example for you to look at: jsFiddle. Feel free to ask any questions.