From c63fb6ed6fc59756fadbc571ee137eb5528fbec1 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Tue, 6 Oct 2020 23:56:27 +0200 Subject: [PATCH] Add image to report and to teleport player --- front/dist/resources/objects/report_flag.png | Bin 0 -> 447 bytes .../dist/resources/objects/teleportation.png | Bin 0 -> 555 bytes front/src/Phaser/Entity/Character.ts | 29 ++++++++++++++++++ front/src/Phaser/Entity/body_character.ts | 27 ++++++++++++++++ front/src/Phaser/Game/GameScene.ts | 19 ++---------- 5 files changed, 59 insertions(+), 16 deletions(-) create mode 100644 front/dist/resources/objects/report_flag.png create mode 100644 front/dist/resources/objects/teleportation.png diff --git a/front/dist/resources/objects/report_flag.png b/front/dist/resources/objects/report_flag.png new file mode 100644 index 0000000000000000000000000000000000000000..57b99126dd322fc798db9765fa10dfdd2195eb9d GIT binary patch literal 447 zcmV;w0YLtVP)amQ`_F&}{9*Y0jS*xDGAQ$%bc^@RcU8sb$MET8c=wBoVZrmC^I5P- z^0EG4uo8QKQ}d6%EDTN8RZm`G*pkJB*BUGU z%O7@zm*06A_I!N3`1}7)FF?wOHb9=|1DMtpc*(%bq*x}wsCMYZ|64n;dg1L)ZidZ| zwHU5`5N9~_Qjy`yZ#EQpJF)vLIif}@_!z}Cu)5&ezki>efBSj+$~PV`|L6x<3^o7$ z|7K8Tu*k=1!1KRv&Mf`7&Y2jmksJ$y+yFDK;29sE{FY$(#;2pl?%qnY0c?z%{6_44 zQ#53Z;{_GDc_p<(#5Bas)AU)rdYKtnQR5H|Fe)=x=14GThN@Yp*s=1WhUt&je;ICF pxVH5f!?l$U|DRiop__q$0Ra6sqZ;yv3L^jj002ovPDHLkV1hgX*C7A^ literal 0 HcmV?d00001 diff --git a/front/dist/resources/objects/teleportation.png b/front/dist/resources/objects/teleportation.png new file mode 100644 index 0000000000000000000000000000000000000000..e13826f9ae2b2c095008601ef503ee1161ce4e49 GIT binary patch literal 555 zcmV+`0@VG9P)JF|xzXlxY<5lU$r8cgr3H$_G8wvQlU zuPXF`3iYb`4ql6R(S)iG5L!Gm7(B$(cC*>@$R^DuO`7~+mibPq$GTGnViUC+Z0 z1EMJ6aDRX2)6voE#IFw$e4$4TV;(dhVY-YdgQq0}9Q1GyO93t0Is13}E~bbn&v~5M zCi6x_H--~ivYhv+wJf?qaCXuCKByDpeV#7bv^+_r;PNL>{PYy1IhU`F!Ivw)nx1PV_FY_RmC!;Bvt}z|Z4isTv6GwttLm)4*J%3aX++XdW%b34`H68HV zhw5dPZmbdd0{2HhSm7 zht2v*e!WOOSMw=K0io($;Nj8=Cg#Rc-!R7yZ>SWoSzg=TaK7B!ZS-9zSSYV<10Svd tDy5Z2_e>8>o3Y-cUMW;*<#Epd{sUbnu8Sxqu5|za002ovPDHLkV1f$k^0xp0 literal 0 HcmV?d00001 diff --git a/front/src/Phaser/Entity/Character.ts b/front/src/Phaser/Entity/Character.ts index 6edb0e36..74a4d99d 100644 --- a/front/src/Phaser/Entity/Character.ts +++ b/front/src/Phaser/Entity/Character.ts @@ -46,6 +46,8 @@ export abstract class Character extends Container { public PlayerValue: string; public sprites: Map; private lastDirection: string = PlayerAnimationNames.WalkDown; + private report: Sprite; + private teleportation: Sprite; constructor(scene: Phaser.Scene, x: number, @@ -62,6 +64,15 @@ export abstract class Character extends Container { for (const texture of textures) { const sprite = new Sprite(scene, 0, 0, texture, frame); + sprite.setInteractive({useHandCursor: true}); + sprite.on('pointerover', () => { + this.report.visible = true; + this.teleportation.visible = true; + }); + sprite.on('pointerup', () => { + this.report.visible = true; + this.teleportation.visible = true; + }); this.add(sprite); this.getPlayerAnimations(texture).forEach(d => { this.scene.anims.create({ @@ -76,6 +87,24 @@ export abstract class Character extends Container { this.sprites.set(texture, sprite); } + this.report = new Sprite(scene, 20, -10, 'report_flag', 3); + this.report.setInteractive(); + this.report.visible = false; + this.report.on('pointerup', () => { + this.report.visible = false; + this.teleportation.visible = false; + }); + this.add(this.report); + + this.teleportation = new Sprite(scene, -20, -10, 'teleportation', 3); + this.teleportation.setInteractive(); + this.teleportation.visible = false; + this.teleportation.on('pointerup', () => { + this.report.visible = false; + this.teleportation.visible = false; + }); + this.add(this.teleportation); + this.PlayerValue = name; this.playerName = new BitmapText(scene, x, y - 25, 'main_font', name, 8); this.playerName.setOrigin(0.5).setCenterAlign().setDepth(99999); diff --git a/front/src/Phaser/Entity/body_character.ts b/front/src/Phaser/Entity/body_character.ts index 3d9d5a5f..50f1eea6 100644 --- a/front/src/Phaser/Entity/body_character.ts +++ b/front/src/Phaser/Entity/body_character.ts @@ -1,4 +1,5 @@ import LoaderPlugin = Phaser.Loader.LoaderPlugin; +import {PLAYER_RESOURCES, PlayerResourceDescriptionInterface} from "./Character"; export interface BodyResourceDescriptionInterface { name: string, @@ -310,3 +311,29 @@ export const loadAllLayers = (load: LoaderPlugin) => { } } } + +export const OBJECTS: Array = [ + {name:'report_flag', img:'resources/objects/report_flag.png'}, + {name:'layout_modes', img:'resources/objects/layout_modes.png'}, + {name:'teleportation', img:'resources/objects/teleportation.png'}, +]; + +export const loadObject = (load: LoaderPlugin) => { + for (let j = 0; j < OBJECTS.length; j++) { + load.spritesheet( + OBJECTS[j].name, + OBJECTS[j].img, + {frameWidth: 32, frameHeight: 32} + ) + } +} + +export const loadPlayerCharacters = (load: LoaderPlugin) => { + PLAYER_RESOURCES.forEach((playerResource: PlayerResourceDescriptionInterface) => { + load.spritesheet( + playerResource.name, + playerResource.img, + {frameWidth: 32, frameHeight: 32} + ); + }); +} diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 608d920b..ed98d9b9 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -16,7 +16,6 @@ import { ITiledMapLayerProperty, ITiledMapObject, ITiledTileSet } from "../Map/ITiledMap"; -import {PLAYER_RESOURCES, PlayerResourceDescriptionInterface} from "../Entity/Character"; import {AddPlayerInterface} from "./AddPlayerInterface"; import {PlayerAnimationNames} from "../Player/Animation"; import {PlayerMovement} from "./PlayerMovement"; @@ -25,7 +24,7 @@ import {RemotePlayer} from "../Entity/RemotePlayer"; import {Queue} from 'queue-typescript'; import {SimplePeer, UserSimplePeerInterface} from "../../WebRtc/SimplePeer"; import {ReconnectingSceneName} from "../Reconnecting/ReconnectingScene"; -import {loadAllLayers} from "../Entity/body_character"; +import {loadAllLayers, loadObject, loadPlayerCharacters} from "../Entity/body_character"; import {CenterListener, layoutManager, LayoutMode} from "../../WebRtc/LayoutManager"; import Texture = Phaser.Textures.Texture; import Sprite = Phaser.GameObjects.Sprite; @@ -189,21 +188,9 @@ export class GameScene extends Phaser.Scene implements CenterListener { } //add player png - PLAYER_RESOURCES.forEach((playerResource: PlayerResourceDescriptionInterface) => { - this.load.spritesheet( - playerResource.name, - playerResource.img, - {frameWidth: 32, frameHeight: 32} - ); - }); - - this.load.spritesheet( - 'layout_modes', - 'resources/objects/layout_modes.png', - {frameWidth: 32, frameHeight: 32} - ); - + loadPlayerCharacters(this.load); loadAllLayers(this.load); + loadObject(this.load); this.load.bitmapFont('main_font', 'resources/fonts/arcade.png', 'resources/fonts/arcade.xml');