用户:
我爱Kitten查看:0 回复:2 评论:0 创建时间:2022-09-22T21:24:02
这是配置代码()()()():
console.clear();
const fnObject = {
'存档点': ({ other }) => {
if (other.isPlayer) {
if (e.position !== other.player.spawnPoint) {
other.player.directMessage('到达新的重生点');
other.player.spawnPoint = e.position;
}
}
},
'落水': ({ entity }) => {
if (!entity.isPlayer) return;
entity.position.copy(entity.player.spawnPoint);
entity.position.y += 4;
},
"设置出生点": ({ entity = new Box3Entity() }) => {
entity.player.spawnPoint = new Box3Vector3(喵, 12, 喵);
entity.position.copy(entity.player.spawnPoint);
}
}
class game {
constructor() { }
async startgame(islog = new Boolean(), isvox = new Boolean(),
isEntity = new Boolean(), voxfn = new Function(),
entityfn = new Function(), isF = new Boolean(),
fFN = new Function(), isonplayer = new Boolean(),
playerfunc = new Function(), isaddCollisionFilter = new Boolean()) {
try {
if (islog) {
console.warn(`欢迎使用跑酷game引擎!
语法如下
1.startgame方法用于初始化跑酷引擎
参数说明:
islog|boolean:是否打印初始文字
isvox|boolean:是否开启方块碰撞
isEntity|boolean:是否开启实体碰撞
voxfn|function:方块碰撞后的回调函数
entityfn|function:实体碰撞的回调函数
isF|boolean:是否开启进入液体
fFN|function:进入液体的回调函数
isonplayer|boolean:是否开启当玩家进入地图
playerfunc|function:当玩家进入地图的回调函数
isaddCollisionFilter|boolean:是否添加玩家之间的碰撞过滤器
===========================
fnObject是脚本回调函数的存储配置,里面包含了一些常用的跑酷代码
===========================
最后,祝你使用愉快!!!!!
可汇报bug或建议,
长期更新。
`);
}
if (isaddCollisionFilter) {
world.addCollisionFilter('player', 'player');
}
if (isvox) {
world.onVoxelContact(event => {
voxfn(event);
})
}
if (isEntity) {
world.onEntityContact(event => {
entityfn(event);
})
}
if (isF) {
world.onFluidEnter(event => {
fFN(event);
})
}
if (isonplayer) {
world.onPlayerJoin((event) => {
playerfunc(event);
})
}
} catch (e) {
throw new Error(`Game_Error:${e}`);
}
}
}
这是示例代码()()():
//简简单单的示例代码()()()
async function gamego() {
const e = new game();
e.startgame(true, false, false, null, null, true, fnObject['落水'], true, fnObject['设置出生点']);
} gamego();
有什么bug或问题或都可以在评论区里说滴()()()()