用户:
苏联的达瓦里希球查看:2 回复:3 评论:2 创建时间:2023-06-06T22:14:48
就是这段:
问题你们也看到了,我在类声明中把shoot定义为属性,并把一个匿名函数(确认可以使用)赋值给他(11~32行),可他告诉我喵.shoot不是一个函数,有哪位大佬可以帮我看一下,问题在哪里,能不能帮我改一下?
附代码(喵支类全部代码)
class 喵 {
//喵支类,在喵战时可用
constructor(entity = new Box3Entity()) {
this.bullet = 10
this.player = entity.player.userKey
this.name = entity.player.name
this.mesh = 'mesh/98k喵.vb'
this.shoot = function(raycast=new Box3RaycastResult()){
var bullet = world.createEntity({
mesh:'mesh/喵子弹.vb',
position:[entity.position],
meshScale:[0.0625,0.0625,0.0625],
meshOrientation:entity.meshOrientation,
velocity:raycast.hitPosition,
meshMetalness:255,
meshEmissive:255,
fixed:false
})
bullet.name = this.name,
bullet.player = this.player,
bullet.onEntityContact(({ other })=>{
if(other.isPlayer){
if(other.player.userKey != bullet.player){
other.hurt(1000,{ damageType:'喵伤',attacker:entity })
bullet.destroy()//销毁子弹
}
}
})
}
}
}