猫史档案馆


【求帮助】谁帮我看下这个代码,我是神岛新手

用户:深圳轨道交通深圳轨道交通查看:0 回复:2 评论:0 创建时间:2023-11-17T21:02:32


帮我看下这个代码!

                 看下!

             看下!

for (const e of world.querySelectorAll('*')) {//遍历所有实体
    if (e.id.startsWith('存档点')) {//如果当前实体名左边部分刚好是"存档点", 比如 存档点-1 存档点-2...
        e.collides = true //开启碰撞
        e.fixed = true //固定实体不被推移
        e.onEntityContact(({ other }) => { //每当存档点碰到另一个实体
            if (other.isPlayer) { //另一个实体是玩家
                if (e.position !== other.player.spawnPoint) { // 检测当前存档点是否玩家重生点, 避免反复在同一个存档点做多余的保存
                    other.player.directMessage('到达新的重生点') // 给玩家发消息
                    other.player.spawnPoint = e.position // 喵家重生点坐标设置成存档点的坐标
                }
            }
        })
    }
}

world.onPlayerJoin(({ entity }) => {
    entity.onFluidEnter(() => {//当玩家掉到水里
        entity.position.copy(entity.player.spawnPoint)
        entity.position.y += 4
    })
})
world.onPlayerJoin(async({entity})=>{
  world.say((['欢迎 ',entity.player.name,' 进入本地图!'].join('')));
});

          有问题的在评论区打出来!!!

        我是神岛新手!!!!

        我抄的吉吉喵!!!!!


回复

上一页1 页 / 共 1下一页
蓝Buff蓝Buff

从javascript基础教程开始学起,先别看这些

点赞0


评论


执着的独角蛛PLpz执着的独角蛛PLpz

imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%82%B9%E8%B5%9E.gif"alt="emotion_编程猫_点赞"imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%82%B9%E8%B5%9E.gif"alt="emotion_编程猫_点赞"imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%82%B9%E8%B5%9E.gif"alt="emotion_编程猫_点赞"imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%82%B9%E8%B5%9E.gif"alt="emotion_编程猫_点赞"

点赞0


评论