用户:
Nomen查看:8 回复:8 评论:8 创建时间:2023-07-29T12:40:10

const p_first = world.querySelector('#弹跳板-1')
p_first.onEntityContact(({ other, axis }) => {
if (axis.y === -1) {
other.velocity.y =5
}
})
const p_Second = world.querySelector('#弹跳板-2')
p_Second.onEntityContact(({ other, axis }) => {
if (axis.y === -1) {
other.velocity.y =5
}
})
这个怎么优化啊大佬?
点赞0
评论
Nomenconst ps = ['#弹跳板-1', '#弹跳板-2'];
ps.forEach(e => {
world.querySelector(e).onEntityContact(({ other, axis }) => {
if (axis.y === -1) {
other.velocity.y = 5
}
})
})点赞0
评论
SCS_user_LoeheodVOQdeveloper.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Number
点赞0
评论