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滚动完成');
    }
}

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

posted @ 2021-07-05 16:10  newmiracle宇宙  阅读(174)  评论(0编辑  收藏  举报