用户:
神岛吉吉喵查看:42 回复:39 评论:42 创建时间:2021-04-15T15:36:20

作为岛上喵的游戏类型
跑酷是很多萌新都会选择的玩法
除了存档功能之外
吉吉喵今天再教你两招
让你的跑酷地图与众不同!
https://www.bilibili.com/video/BV1CZ4y1c7MP
弹射板代码:
const pad = world.querySelector('#弹射跳板-1')
pad.onEntityContact(({ other, axis }) => {
if (axis.y === -1) { // 如果是往下踩
other.velocity.y = 2 // 设置玩家的瞬时y轴速度为2
}
})
加速带代码:
const speedBump = world.querySelector('#加速带-1')
speedBump.onEntityContact(async ({ other }) => {
if (other.isPlayer) {
if (other.speedUp) {
return //如果已经在加速中就不再加速
}
other.speedUp = true
//记住正常的速度
const oldSpeed = other.player.runSpeed
const oldAccel = other.player.runAcceleration
//双倍速度
other.player.runSpeed *= 2
other.player.runAcceleration *= 2
await sleep(1000) // 等待一秒
//恢复正常速度
other.player.runSpeed = oldSpeed
other.player.runAcceleration = oldAccel
other.speedUp = false
}
})

开发API文档:https://docs.box3.codemao.cn/
加入代码岛3.0官方内测Q喵
下面的二维码会扫出来什么呢?( =•ω•= )m

imgsrc="https://static.cod喵/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E5%86%B7%E6%BC%A0.gif"alt="emotion_编程猫_冷漠"
点赞0
评论