Fix feedback @moufmouf on circle texture
authorgparant <g.parant@thecodingmachine.com>
Sun, 10 May 2020 15:55:30 +0000 (17:55 +0200)
committergparant <g.parant@thecodingmachine.com>
Sun, 10 May 2020 15:55:30 +0000 (17:55 +0200)
front/src/Phaser/Game/GameScene.ts

index 26c2fc355ba036d726977d3134d42b1e0c7e7d1c..782714925c2f6e02faaf630bd0da121a96613388 100644 (file)
@@ -69,9 +69,11 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface, Creat
                     console.warn("Don't know how to handle tileset ", tileset)
                     return;
                 }
+                //TODO strategy to add access token
                 this.load.image(tileset.name, `${this.MapUrlFile}/${tileset.image}`);
             })
         });
+        //TODO strategy to add access token
         this.load.tilemapTiledJSON(this.MapKey, `${this.MapUrlFile}/${this.MapKey}.json`);
 
         //add player png
@@ -139,18 +141,17 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface, Creat
 
 
         // Let's generate the circle for the group delimiter
-        //TODO they are error with cercle
-        this.circleTexture = this.textures.createCanvas('circleSprite', 96, 96);
-        if(!this.circleTexture || this.circleTexture.context){
-            return;
+        let circleElement = Object.values(this.textures.list).find((object: Texture) => object.key === 'circleSprite');
+        if(circleElement) {
+            this.textures.remove('circleSprite');
         }
+        this.circleTexture = this.textures.createCanvas('circleSprite', 96, 96);
         let context = this.circleTexture.context;
         context.beginPath();
         context.arc(48, 48, 48, 0, 2 * Math.PI, false);
         // context.lineWidth = 5;
         context.strokeStyle = '#ffffff';
         context.stroke();
-
         this.circleTexture.refresh();
     }
 
@@ -399,7 +400,11 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface, Creat
             this.groups.get(groupId).setPosition(Math.round(groupPositionMessage.position.x), Math.round(groupPositionMessage.position.y));
         } else {
             // TODO: circle radius should not be hard stored
-            let sprite = new Sprite(this, Math.round(groupPositionMessage.position.x), Math.round(groupPositionMessage.position.y), 'circleSprite');
+            let sprite = new Sprite(
+                this,
+                Math.round(groupPositionMessage.position.x),
+                Math.round(groupPositionMessage.position.y),
+                'circleSprite');
             sprite.setDisplayOrigin(48, 48);
             this.add.existing(sprite);
             this.groups.set(groupId, sprite);