pixijs+alloytouch滚动地图的写法
pixijs+alloytouch滚动地图的写法
<script src="js/pixi.min.js" type="text/javascript"> </script> <script src="js/alloytouch.js" type="text/javascript"> </script> <script type="text/javascript"> const app = new PIXI.Application({ width: 750, height: 1206 }); document.body.appendChild(app.view); const container = new PIXI.Container(); app.stage.addChild(container); // Create a new texture const texture = PIXI.Texture.from('https://pixijs.io/examples/examples/assets/bunny.png'); // Create a 5x5 grid of bunnies for (let i = 0; i < 25; i++) { const bunny = new PIXI.Sprite(texture); bunny.anchor.set(0.5); bunny.x = i * 40; bunny.y =i* 240; container.addChild(bunny); } var alloyTouch=new AlloyTouch({ touch:'body', vertical:true, maxSpeed:0.8, max:0, min:-3000, bindSelf:false, initialValue:0, change:function(value){ console.log(value); container.y=value } }) </script>
如果遇到什么不懂的地方直接关注公众号留言(本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须在文章页面给出原文连接,否则保留追究法律责任的权利。)
作者:newmiracle
出处:https://www.cnblogs.com/newmiracle/