用户:
Chara_juchuief_exe查看:14 回复:12 评论:14 创建时间:2020-03-26T11:04:31
(function(/* 传送模块 */) {
// 存档点和传送点允许放置多个
// 传送点的实体需要加上标签 传送点
// 存档点的实体需要加上标签 存档点
// 存档点和传送点的实体需要开启 实体化
const checkPoint = {};
world.querySelectorAll('.存档点').forEach((e) => e.onEntityContact(({entity, other}) => {
if (other.isPlayer) {
checkPoint[other.player.name] = entity.position;//玩家碰到存档点,就会记录下玩家的名字,以及该存档点的位置
}
}));
world.querySelectorAll('.传送点').forEach((e) => e.onEntityContact(({entity, other}) => {
if (other.isPlayer && other.player.name in checkPoint) {
//如果玩家碰到传送点,且玩家的名字有记录在存档点,则传送玩家
other.position.copy(checkPoint[other.player.name]);
other.position.y += 40; // 传送到存档点的上方, 然后会自动落下
}
}));
})();