猫史档案馆


【代码岛3】【教程】电梯制作

用户:迷失冷光迷失冷光查看:11 回复:36 评论:11 创建时间:2020-08-10T14:23:49


今天我们来导论一下:

电梯制作!

效果:

center_image

center_image

方法:

1.新建一个实体,加标签:电梯

2.新建两扇门(上门和下门,副标签)

3.开门函数代码:

async function openDoor(theDoor){
    world.querySelectorAll(theDoor).forEach(async(door)=>{
        for(door.time=0;door.time<31;door.time++){
            door.position.x -= 0.1;
            await sleep(50);
        }
        await sleep(5000);
        for(door.time=0;door.time<31;door.time++){
            door.position.x += 0.1;
            await sleep(50);
        }
    })
}

喵的屏蔽词!

4.电梯代码:

world.querySelectorAll('.电梯').forEach(async(t)=>{
    while(true){
        openDoor('.下门');//打开下门
        await sleep(8000);
        for(t.time=0;t.time<50;t.time++){
            t.position.y += 0.1;
            await sleep(100);        
        }
        openDoor('.上门');//打开上门
        await sleep(8000);
        for(t.time=0;t.time<50;t.time++){
            t.position.y -= 0.1;
            await sleep(100);        
        }
    }
})

制作完成就能得到我们想要的电梯代码啦!


回复

上一页1 页 / 共 2下一页
ZNS_RemytowerJimmyZNS_RemytowerJimmy

喵为n c

点赞0


评论


BlueedgeBlueedge

666

 

点赞0


评论


YLG_战神_皮卡YLG_战神_皮卡

大佬求发蓝色代码

点赞0


评论


AbnormalLOGAbnormalLOG

收藏~

点赞0


评论


AbnormalLOGAbnormalLOG

emotion_编程猫_厉害了

点赞0


评论


凌_墨水凌_墨水

注释还是不够详细,加油

点赞0


评论


JerryLKJJerryLKJ

喵:n c

点赞0


评论


可靠的蓝甲虫sDuG可靠的蓝甲虫sDuG

async function openDoor(theDoor){
    world.querySelectorAll(theDoor).forEach(async(door)=>{
        for(door.time=0;door.time<31;door.time++){
            door.position.x -= 0.1;
            await sleep(50);
        }
        await sleep(5000);
        for(door.time=0;door.time<31;door.time++){
            door.position.x += 0.1;
            await sleep(50);
        }
    })
}
world.querySelectorAll('.电梯').forEach(async(t)=>{
    while(true){
        openDoor('.下门');//打开下门
        await sleep(8000);
        for(t.time=0;t.time<50;t.time++){
            t.position.y += 0.1;
            await sleep(100);        
        }
        openDoor('.上门');//打开上门
        await sleep(8000);
        for(t.time=0;t.time<50;t.time++){
            t.position.y -= 0.1;
            await sleep(100);        
        }
    }
})

点赞0


评论


GZ006GZ006

nc现在不是屏蔽词了

点赞0


评论


卫道士32_32*2没了卫道士32_32*2没了

async

 

点赞0


评论


lon江航lon江航

emotion_编程猫_点赞

点赞0


评论


LUS圣武士LUS圣武士

nc

点赞0


评论


雾蓁雾蓁

emotion_编程猫_点赞

点赞0


评论


治愈绾兮治愈绾兮

为啥我报错了

点赞1


评论


亿只懒Ink亿只懒Ink

awa大佬求做师傅

点赞0


评论


学霸8号学霸8号

emotion_编程猫_点赞

点赞0


评论


IaeaIaea

666

点赞0


评论


中國萬歲_青铁迷中國萬歲_青铁迷

我运行不了

点赞0


评论


迷失冷光迷失冷光

我挖

点赞1


评论


云游box3der尖头叉子云游box3der尖头叉子

考古

点赞0


评论


星海茫茫_tammy星海茫茫_tammy

考古

点赞0


评论


小树同学小树同学

这么老的电梯能用吗?上次维修是8个月以前的时了呢

点赞0


评论


ZCH123AbaB退喵倒438894ZCH123AbaB退喵倒438894

谢谢大佬

点赞0


评论


一勺小汤_纪念号一勺小汤_纪念号

考个古

点赞0


评论


_function__function_

琪贵,你去武器试验场看看我写的代码,然后发布一下

点赞0


评论


_function__function_

您把地图要不发布一下?

点赞0


评论


星辰Lolita星辰Lolita

center_image

点赞0


评论


BXS_asteroidBXS_asteroid

()()

点赞1


评论


还是那个小橙子丫还是那个小橙子丫

(

 

点赞0


评论


WitheredWonderWitheredWonder

挖坟

点赞0


评论