如何解决Phaser3 多人服务器/客户端游戏中的碰撞处理
我有一个关于如何在 Phaser3 多人游戏中处理物理问题的问题。
我在尝试处理碰撞时遇到了问题,因为服务器的 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 举报,一经查实,本站将立刻删除。