From ba3f0e07f83b1ccb94e36532c4557743a25f209d Mon Sep 17 00:00:00 2001 From: gparant Date: Mon, 13 Apr 2020 16:53:19 +0200 Subject: [PATCH 1/2] Refactor sizing hitbox charactere --- front/src/Phaser/Entity/PlayableCaracter.ts | 3 ++- front/src/Phaser/Player/Player.ts | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/front/src/Phaser/Entity/PlayableCaracter.ts b/front/src/Phaser/Entity/PlayableCaracter.ts index 66ddd579..3a18ea73 100644 --- a/front/src/Phaser/Entity/PlayableCaracter.ts +++ b/front/src/Phaser/Entity/PlayableCaracter.ts @@ -14,7 +14,8 @@ export class PlayableCaracter extends Phaser.Physics.Arcade.Sprite { this.scene.physics.world.enableBody(this); this.setImmovable(true); this.setCollideWorldBounds(true); - this.setSize(32, 32); //edit the hitbox to better match the caracter model + this.setSize(16, 16); //edit the hitbox to better match the caracter model + this.setOffset(8, 16); } move(x: number, y: number){ diff --git a/front/src/Phaser/Player/Player.ts b/front/src/Phaser/Player/Player.ts index d0169297..e2d7d692 100644 --- a/front/src/Phaser/Player/Player.ts +++ b/front/src/Phaser/Player/Player.ts @@ -50,8 +50,6 @@ export class Player extends PlayableCaracter implements CurrentGamerInterface, G //the current player model should be push away by other players to prevent conflict this.setImmovable(false); - //edit the hitbox to better match the caracter model - this.setSize(32, 32); } initAnimation(): void { From d6653c61ccf74d6a6c65168a2249cbaded7b37b5 Mon Sep 17 00:00:00 2001 From: gparant Date: Mon, 13 Apr 2020 16:56:06 +0200 Subject: [PATCH 2/2] Add comment talk when user have a collision & comment collision shwon --- front/src/Phaser/Game/GameScene.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 8665fd2f..48acf4a2 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -94,16 +94,16 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface{ //add collision layer this.Layers.forEach((Layer: Phaser.Tilemaps.StaticTilemapLayer) => { this.physics.add.collider(this.CurrentPlayer, Layer, (object1: any, object2: any) => { - this.CurrentPlayer.say("Collision with layer : "+ (object2 as Tile).layer.name) + //this.CurrentPlayer.say("Collision with layer : "+ (object2 as Tile).layer.name) }); Layer.setCollisionByProperty({collides: true}); //debug code //debug code to see the collision hitbox of the object in the top layer - Layer.renderDebug(this.add.graphics(), { + /*Layer.renderDebug(this.add.graphics(), { tileColor: null, //non-colliding tiles collidingTileColor: new Phaser.Display.Color(243, 134, 48, 200), // Colliding tiles, faceColor: new Phaser.Display.Color(40, 39, 37, 255) // Colliding face edges - }); + });*/ }); } @@ -115,7 +115,7 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface{ createCollisionObject(){ this.Objects.forEach((Object : Phaser.Physics.Arcade.Sprite) => { this.physics.add.collider(this.CurrentPlayer, Object, (object1: any, object2: any) => { - this.CurrentPlayer.say("Collision with object : " + (object2 as Phaser.Physics.Arcade.Sprite).texture.key) + //this.CurrentPlayer.say("Collision with object : " + (object2 as Phaser.Physics.Arcade.Sprite).texture.key) }); }) }