javascript循环滚动游戏地图的写法

javascript循环滚动游戏地图的写法

1 初始化2个地图位置

2 定时器滚动2个地图

3  如果1个地图超出了 就初始化位置 

function gundongditu() {
    if (yikaiqi == 0) {
        return false;
    }
    speed = 3 + parseInt(gundongcishu / 1);
    daolucontainer1.y += speed;
    if (daolucontainer1.y >= gundonglimit) {
        console.log(daolucontainer1.parent);
        daolucontainer1.parent.removeChild(daolucontainer1);
        daolucontainer1 = daolucontent(daolucontainer2y);
        gundongcishu++;
        console.log('daolucontainer1滚动完成');
    }
    daolucontainer2.y += speed;
    if (daolucontainer2.y >= gundonglimit) {
        daolucontainer2.parent.removeChild(daolucontainer2);
        daolucontainer2 = daolucontent(daolucontainer2y);
        gundongcishu++;
        console.log('daolucontainer2滚动完成');
    }
}

上面代码可以封装下的 我只是初步写了下


如果遇到什么不懂的地方直接关注公众号留言(本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须在文章页面给出原文连接,否则保留追究法律责任的权利。)
作者:newmiracle
出处:https://www.cnblogs.com/newmiracle/

 
原文地址:https://www.cnblogs.com/newmiracle/p/14972913.html