Phaser3 多人服务器/客户端游戏中的碰撞处理

问题描述

我有一个关于如何在 Phaser3 多人游戏中处理物理问题的问题。

  1. 我有一个客户端,我正在使用图层加载我的瓦片地图。
  2. 我有一台服务器,负责处理所有游戏物理。

我在尝试处理碰撞时遇到了问题,因为服务器的 game.js 脚本包含物理所在的配置:

const config = {
type: Phaser.HEADLESS,parent: 'phaser-example',width: 800,height: 600,autoFocus: false,physics: {
    default: 'arcade',arcade: {
        debug: false,gravity: { y: 0 }
    }
},scene: {
    preload: preload,create: create,update: update
}};
.........
function create() {

const self = this;
this.players = this.physics.add.group();

this.scores = {
    blue: 0,red: 0
};

this.star = this.physics.add.image(randomPosition(700),randomPosition(500),'star');

this.physics.add.collider(this.players);.......

另一方面,我在客户端添加了 tilemap:

function preload() {
this.load.tilemapTiledJSON('map1','assets/maps/map1/level1.json');
this.load.image('background','assets/maps/map1/background.png');
this.load.image('tiles','assets/maps/map1/platformPack_tilesheet.png');

this.load.image('ship','assets/spaceShips_001.png');
this.load.image('otherPlayer','assets/enemyBlack5.png');
this.load.image('star','assets/star_gold.png');
}

function create() {

const backgroundImage = this.add.image(0,'background').setorigin(0,0);
backgroundImage.setScale(2,0.8);

const map = this.make.tilemap({key:'map1'});

const tileset = map.addTilesetimage('platformPack_tilesheet','tiles');

const platforms = map.createStaticLayer('Platforms',tileset,200);
map.setCollisionByExclusion(-1,true);............

问题是我不知道怎么用

physics.add.collider(this.players,this.platforms);

处理碰撞,因为我在客户端没有物理。 我将不胜感激任何有关代码的帮助,或有关移相多人游戏中物理的文章或如何实现它的任何想法。

谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...