用户:
小电鼠vdc1查看:2 回复:1 评论:2 创建时间:2022-07-03T11:55:41
world.onPress(async ({ entity, button, raycast: { voxelIndex, normal, distance } }) => {//监听按下去 if (distance <= 8) {//重点!如果距离小于8!我的世界的属性! entity.player.enable3DCursor = true // 开启方块光标 if (button == Box3ButtonType.ACTION1) { //如果是action1,即电脑端的右键 let v = voxelIndex.add(normal); //用点击到的方块坐标加上法向量,得到邻边方块 voxels.setVoxel(v.x, v.y, v.z, entity.player.hand); //设置邻边方块为entity.player.hand } else if (button == Box3ButtonType.ACTION0) { //如果是action0,对应电脑端左键 const selection = await entity.player.dialog({ type: Box3DialogType.SELECT, content: '选择方块类型', options: ['grass', 'stone', 'dirt', 'lantern_01', 'lava01', 'ice', 'water'], }) if (selection) { entity.player.hand = selection.value // 更新玩家当前选定方块 } } } }) 如何才能做到按E打开菜单(代码红色部分)求 左键摧毁,右键放置菜单中选则的方块 求