From 1359fbe97768c485c033eecd6e588222e836f931 Mon Sep 17 00:00:00 2001 From: kharhamel Date: Wed, 6 Jan 2021 15:00:54 +0100 Subject: [PATCH] updated phaser to version 3.51 and fixed the BC --- front/src/Phaser/Entity/Character.ts | 4 ++-- front/src/Phaser/Entity/RemotePlayer.ts | 3 ++- front/src/Phaser/Entity/SpeechBubble.ts | 2 +- front/src/Phaser/Game/GameScene.ts | 10 +++++----- front/src/Phaser/Items/ActionableItem.ts | 3 +-- front/src/Phaser/Shaders/OutlinePipeline.ts | 4 +--- front/src/index.ts | 2 +- front/yarn.lock | 18 +++++++++--------- 8 files changed, 22 insertions(+), 24 deletions(-) diff --git a/front/src/Phaser/Entity/Character.ts b/front/src/Phaser/Entity/Character.ts index 5c89447e..37b55be2 100644 --- a/front/src/Phaser/Entity/Character.ts +++ b/front/src/Phaser/Entity/Character.ts @@ -227,7 +227,7 @@ export abstract class Character extends Container { }, 3000) } - destroy(fromScene?: boolean): void { + destroy(): void { if (this.scene) { this.scene.events.removeListener('postupdate', this.postupdate.bind(this)); } @@ -236,7 +236,7 @@ export abstract class Character extends Container { this.scene.sys.updateList.remove(sprite); } } - super.destroy(fromScene); + super.destroy(); this.playerName.destroy(); } } diff --git a/front/src/Phaser/Entity/RemotePlayer.ts b/front/src/Phaser/Entity/RemotePlayer.ts index 08f657d4..54592389 100644 --- a/front/src/Phaser/Entity/RemotePlayer.ts +++ b/front/src/Phaser/Entity/RemotePlayer.ts @@ -29,6 +29,7 @@ export class RemotePlayer extends Character { this.playAnimation(position.direction, position.moving); this.setX(position.x); this.setY(position.y); - this.setDepth(position.y); + + this.setDepth(position.y); //this is to make sure the perspective (player models closer the bottom of the screen will appear in front of models nearer the top of the screen). } } diff --git a/front/src/Phaser/Entity/SpeechBubble.ts b/front/src/Phaser/Entity/SpeechBubble.ts index 30518890..5dc43fe0 100644 --- a/front/src/Phaser/Entity/SpeechBubble.ts +++ b/front/src/Phaser/Entity/SpeechBubble.ts @@ -52,7 +52,7 @@ export class SpeechBubble { this.bubble.lineBetween(point2X, point2Y, point3X, point3Y); this.bubble.lineBetween(point1X, point1Y, point3X, point3Y); - this.content = scene.add.text(0, 0, text, { fontFamily: 'Arial', fontSize: 20, color: '#000000', align: 'center', wordWrap: { width: bubbleWidth - (bubblePadding * 2) } }); + this.content = scene.add.text(0, 0, text, { fontFamily: 'Arial', fontSize: '20', color: '#000000', align: 'center', wordWrap: { width: bubbleWidth - (bubblePadding * 2) } }); const bounds = this.content.getBounds(); this.content.setPosition(this.bubble.x + (bubbleWidth / 2) - (bounds.width / 2), this.bubble.y + (bubbleHeight / 2) - (bounds.height / 2)); diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index a8206328..99b002de 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -110,7 +110,7 @@ export class GameScene extends ResizableScene implements CenterListener { MapPlayers!: Phaser.Physics.Arcade.Group; MapPlayersByKey : Map = new Map(); Map!: Phaser.Tilemaps.Tilemap; - Layers!: Array; + Layers!: Array; Objects!: Array; mapFile!: ITiledMap; groups: Map; @@ -342,11 +342,11 @@ export class GameScene extends ResizableScene implements CenterListener { this.physics.world.setBounds(0, 0, this.Map.widthInPixels, this.Map.heightInPixels); //add layer on map - this.Layers = new Array(); + this.Layers = new Array(); let depth = -2; for (const layer of this.mapFile.layers) { if (layer.type === 'tilelayer') { - this.addLayer(this.Map.createStaticLayer(layer.name, this.Terrains, 0, 0).setDepth(depth)); + this.addLayer(this.Map.createLayer(layer.name, this.Terrains, 0, 0).setDepth(depth)); const exitSceneUrl = this.getExitSceneUrl(layer); if (exitSceneUrl !== undefined) { @@ -824,13 +824,13 @@ export class GameScene extends ResizableScene implements CenterListener { this.cameras.main.setZoom(ZOOM_LEVEL); } - addLayer(Layer : Phaser.Tilemaps.StaticTilemapLayer){ + addLayer(Layer : Phaser.Tilemaps.TilemapLayer){ this.Layers.push(Layer); } createCollisionWithPlayer() { //add collision layer - this.Layers.forEach((Layer: Phaser.Tilemaps.StaticTilemapLayer) => { + this.Layers.forEach((Layer: Phaser.Tilemaps.TilemapLayer) => { this.physics.add.collider(this.CurrentPlayer, Layer, (object1: GameObject, object2: GameObject) => { //this.CurrentPlayer.say("Collision with layer : "+ (object2 as Tile).layer.name) }); diff --git a/front/src/Phaser/Items/ActionableItem.ts b/front/src/Phaser/Items/ActionableItem.ts index 36b14921..a1548f41 100644 --- a/front/src/Phaser/Items/ActionableItem.ts +++ b/front/src/Phaser/Items/ActionableItem.ts @@ -43,8 +43,7 @@ export class ActionableItem { } this.isSelectable = true; this.sprite.setPipeline(OutlinePipeline.KEY); - this.sprite.pipeline.setFloat2('uTextureSize', - this.sprite.texture.getSourceImage().width, this.sprite.texture.getSourceImage().height); + this.sprite.pipeline.set2f('uTextureSize', this.sprite.texture.getSourceImage().width, this.sprite.texture.getSourceImage().height); } /** diff --git a/front/src/Phaser/Shaders/OutlinePipeline.ts b/front/src/Phaser/Shaders/OutlinePipeline.ts index 6b416b8a..0d074bc3 100644 --- a/front/src/Phaser/Shaders/OutlinePipeline.ts +++ b/front/src/Phaser/Shaders/OutlinePipeline.ts @@ -1,5 +1,4 @@ -export class OutlinePipeline extends Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline -{ +export class OutlinePipeline extends Phaser.Renderer.WebGL.Pipelines.MultiPipeline { // the unique id of this pipeline public static readonly KEY = 'Outline'; @@ -11,7 +10,6 @@ export class OutlinePipeline extends Phaser.Renderer.WebGL.Pipelines.TextureTint { super({ game: game, - renderer: game.renderer, fragShader: ` precision mediump float; diff --git a/front/src/index.ts b/front/src/index.ts index c8783b90..46d38a3b 100644 --- a/front/src/index.ts +++ b/front/src/index.ts @@ -75,7 +75,7 @@ const config: GameConfig = { postBoot: game => { // FIXME: we should fore WebGL in the config. const renderer = game.renderer as WebGLRenderer; - renderer.addPipeline(OutlinePipeline.KEY, new OutlinePipeline(game)); + renderer.pipelines.add(OutlinePipeline.KEY, new OutlinePipeline(game)); } } }; diff --git a/front/yarn.lock b/front/yarn.lock index 02b6052b..a31409a6 100644 --- a/front/yarn.lock +++ b/front/yarn.lock @@ -1771,7 +1771,7 @@ eventemitter3@^2.0.3: resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-2.0.3.tgz#b5e1079b59fb5e1ba2771c0a993be060a58c99ba" integrity sha1-teEHm1n7XhuidxwKmTvgYKWMmbo= -eventemitter3@^4.0.0, eventemitter3@^4.0.4: +eventemitter3@^4.0.0, eventemitter3@^4.0.7: version "4.0.7" resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw== @@ -1829,7 +1829,7 @@ expand-tilde@^2.0.0, expand-tilde@^2.0.2: dependencies: homedir-polyfill "^1.0.1" -exports-loader@^1.1.0: +exports-loader@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/exports-loader/-/exports-loader-1.1.1.tgz#88c9a6877ee6a5519d7c41a016bdd99148421e69" integrity sha512-CmyhIR2sJ3KOfVsHjsR0Yvo+0lhRhRMAevCbB8dhTVLHsZPs0lCQTvRmR9YNvBXDBxUuhmCE2f54KqEjZUaFrg== @@ -2528,7 +2528,7 @@ import-local@^2.0.0: pkg-dir "^3.0.0" resolve-cwd "^2.0.0" -imports-loader@^1.1.0: +imports-loader@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/imports-loader/-/imports-loader-1.2.0.tgz#b06823d0bb42e6f5ff89bc893829000eda46693f" integrity sha512-zPvangKEgrrPeqeUqH0Uhc59YqK07JqZBi9a9cQ3v/EKUIqrbJHY4CvUrDus2lgQa5AmPyXuGrWP8JJTqzE5RQ== @@ -3664,13 +3664,13 @@ pbkdf2@^3.0.3: sha.js "^2.4.8" phaser@^3.22.0: - version "3.24.1" - resolved "https://registry.yarnpkg.com/phaser/-/phaser-3.24.1.tgz#376e0c965d2a35af37c06ee78627dafbde5be017" - integrity sha512-WbrRMkbpEzarkfrq83akeauc6b8xNxsOTpDygyW7wrU2G2ne6kOYu3hji4UAaGnZaOLrVuj8ycYPjX9P1LxcDw== + version "3.51.0" + resolved "https://registry.yarnpkg.com/phaser/-/phaser-3.51.0.tgz#b0c7ee2b21e795830d74f476dd30816a42b023bd" + integrity sha512-Z7XNToZWO60Zx/YetaoeGSeELy5ND45TPPfYB9HtQU2692ACXc/nioQaWp20NzTMgeBsgl6vYf3CI82y/DzSyg== dependencies: - eventemitter3 "^4.0.4" - exports-loader "^1.1.0" - imports-loader "^1.1.0" + eventemitter3 "^4.0.7" + exports-loader "^1.1.1" + imports-loader "^1.2.0" path "^0.12.7" picomatch@^2.0.4, picomatch@^2.0.5, picomatch@^2.2.1: