猫史档案馆


【干货】box3中的计时器

用户:1232RvE1232RvE查看:0 回复:3 评论:0 创建时间:2021-05-01T07:55:35


跑酷好玩吗??? 跑酷好玩吗!?? 跑酷好玩吗!!? 当然好玩,但是更好玩的莫过于做跑酷。 想想1000行+的代码,色(hua)彩(li)斑(hu)斓(shao)的地图,9999+的点击量,999+的评论…… 美滋滋啊 但是…… 大家见过吉吉喵《一起跑酷》里边的计时器么 【群众】:好难做 没事,我今儿就教教你们。 varbestResult=Infinity; 咳咳,跑酷肯定要有一个最高记录啊,但是用时越短越好,so,infinity是【无穷大】哦!!!! world.querySelectorAll(".终点").forEach((e)=>{ e.onEntityContact(({other})=>{ 遍列标签为“终点”的实体【一定要开实体化】碰撞【踩在脚下也行】, varnow=newDate().valueOf(); varname=other.player.name; 第一行是现在的时间【跑完】,第二行是看【谁】跑完了, other.player.time=(now-other.player.starttime)/1000; if(other.player.time<bestResult){ bestResult=other.player.time; world.say(`恭喜@${name}以${other.player.time}秒的成绩打破记录!`); }else{ world.say(`@${name}跑完一圈,用时${other.player.time}秒.`); } world.say(`${other.player.name}已获得飞行+幽灵能力,其他的玩家们,加油哦`) other.canFly=true; other.player.spectator=true }) }) 这个是跑完播报,飞行+幽灵, 记得在前面加上 world.onPlayerJoin(({entity})=>{ entity.player.starttime=newDate().valueOf(); }) 这是玩家进来的时间, 到终点的时间-进来的时间=跑酷中所用的时间。 这篇文章对你有帮助吗? 有的话记得关注我哦 我们下期债见!!! byebye~


回复

上一页1 页 / 共 1下一页
一勺小汤_纪念号一勺小汤_纪念号

用岛三图形化编辑不香吗

点赞1


评论


1232RvE1232RvE

点赞0


评论


薹灣解放再改名薹灣解放再改名

 world.querySelectorAll(".终点").forEach((e)=>{ e.onEntityContact(({other})=>{, varnow=newDate().valueOf(); varname=other.player.name; other.player.time=(now-other.player.starttime)/1000; if(other.player.time<bestResult){ bestResult=other.player.time; world.say(`恭喜@${name}以${other.player.time}秒的成绩打破记录!`); }else{ world.say(`@${name}跑完一圈,用时${other.player.time}秒.`); } world.say(`${other.player.name}已获得飞行+幽灵能力,其他的玩家们,加油哦`) other.canFly=true; other.player.spectator=true }) }) world.onPlayerJoin(({entity})=>{ entity.player.starttime=newDate().valueOf(); })

点赞0


评论