Lv.1
会C++,正在学习Java
在 则么与玩家互动 中回复
岛三吗?
world.onPlayerJoin(({ entity }) => {//有玩家进入地图时
entity.player.showName = false //为有更好的效果,隐藏玩家的名字(否则会很奇怪)
entity.enableInteract = true //允许实体互动
entity.interactRadius = 5 //互动范围
entity.interactHint = `和 "${entity.player.name}" 互动` //可以互动时显示的文字
})
world.onInteract(async ({ entity, targetEntity }) => {
const result = await entity.player.dialog({
type: Box3DialogType.SELECT,
title: "系统",
lookEye: entity,
lookTarget: targetEntity,
content: `向" ${targetEntity.player.name} "互动`,
options: ['对话', '取消'],
});
if (result.index === 0) {
const result1 = await entity.player.dialog({
type: Box3DialogType.INPUT,
title: "系统",
lookTarget: entity,
content: `请输入对话内容`,
confirmText: "发出对话"
});
if (result1 != null) {
targetEntity.player.dialog({
type: Box3DialogType.TEXT,
title: entity.player.name,
content: result1,
});
}
}
});2021-11-09T13:32:47 点赞:0
在 【box3】代码分享:和其他玩家互动! 中回复
补充一下hh
world.onPlayerJoin(({ entity }) => {//有玩家进入地图时
entity.player.showName = false //为有更好的效果,隐藏玩家的名字(否则会很奇怪)
entity.enableInteract = true //允许实体互动
entity.interactRadius = 5 //互动范围
entity.interactHint = `和 "${entity.player.name}" 互动` //可以互动时显示的文字
})
world.onInteract(async ({ entity, targetEntity }) => {
const result = await entity.player.dialog({
type: Box3DialogType.SELECT,
title: "系统",
lookEye: entity,
lookTarget: targetEntity,
content: `向" ${targetEntity.player.name} "互动`,
options: ['对话', '取消'],
});
if (result.index === 0) {
const result1 = await entity.player.dialog({
type: Box3DialogType.INPUT,
title: "系统",
lookTarget: entity,
content: `请输入对话内容`,
confirmText: "发出对话"
});
if (result1 != null) {
targetEntity.player.dialog({
type: Box3DialogType.TEXT,
title: entity.player.name,
content: result1,
});
}
}
});2021-11-09T13:34:23 点赞:0
在 【岛三代码教程】如何做出玩家之间互动的效果 中回复
2021-12-05T12:05:19 点赞:0
在 【box3代码问题】谁有反挂机的代码 中回复
console.clear()
world.onPlayerJoin(({ entity }) => {
entity.gj = false
world.onTick((tick) => {
if (entity.player.walkState == Box喵layerWalkState.NONE) {
if (entity.gj == false) {
entity.gjtick = tick.tick;//纪录开始挂机的tick
}
entity.gj = true//将挂机状态改为true
world.addCollisionFilter(entity,'player');
if (Math.abs(entity.gjtick - tick.tick) >= 156) {//一tick是喵毫秒,因此10秒就是156.25,四舍五入156tick
entity.player.spectator=true
}
} else { //如果不想移动后自动取消挂机,去掉else部分
world.removeCollisionFilter(entity,'player');
entity.gj = false//将挂机状态改为false
entity.player.spectator=false
}
})
})
2022-01-23T12:47:08 点赞:1
在 【官方】如何上首页?只需在本帖下面评论! 中回复
shequ.codemao.cn/work/139879378 双人多房间联机作品——数字炸弹 imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E6%90%93%E5%A4%B4.gif"alt="emotion_编程猫_搓头"
2022-03-22T20:12:26 点赞:0