用户:
神岛吉吉喵查看:135 回复:119 评论:135 创建时间:2020-01-22T21:09:28
- 1. 新地图 -
「打年兽!迎新春!」
传说中,每逢过年,
就有一只年兽降临人间。
人们要打败年兽,
才能迎接新年!

- 2. 编辑器更新 -
新增伤害系统!
你一定很好奇,
打年兽的代码是怎么写的?
答案就是
代码岛3.0代码新增了伤害系统!
让任意实体、玩家变成可攻击的。
示例代码
//一个简单的射击PvP
world.onPlayerJoin(({ entity }) => {
entity.enableDamage = true;
entity.player.onPress(({ button, raycast:{ hitEntity, direction } }) => {
if (button !== 'action0' || !hitEntity) {
return;
}
hitEntity.velocity.x += direction.x;
hitEntity.velocity.y += 0.5;
hitEntity.velocity.z += direction.z;
hitEntity.hurt(20 * Math.random() + 5, {
attacker: entity,
});
});
});
world.onDie(({ entity, attacker }) => {
if (attacker) {
world.say(attacker.player.name + ' killed ' + entity.player.name)
}
entity.player.forceRespawn();
});

- 3. 高级用法更新 -
新增异步代码
代码岛3.0代码编辑器现在支持promise啦!
可以做什么?
👇
示例代码
//倒计时3秒后,世界喊:开始!
async function countDown () {
for (let count = 3; count > 0; --count) {
world.say(count + '...');
await sleep(1000);
}
world.say('开始!');
}

- 4. 特别活动 -
「新年倒计时」
除夕晚上23:50
「打年兽!迎新春!」地图
大合照+新年倒计时!
不见不散