From adb5c114692e70ddc637aeef0138eac7bbc44463 Mon Sep 17 00:00:00 2001 From: Tiago Schenkel Date: Fri, 13 May 2022 19:35:57 +0100 Subject: [PATCH] upgrade pixi.js to v6 --- games/space-invaders/package.json | 2 +- games/space-invaders/src/Game.ts | 13 +++++-------- .../src/mediators/GameOverPopupMediator.ts | 4 ++-- .../src/mediators/HUDGameComponentMediator.ts | 2 +- .../src/mediators/HomeViewMediator.ts | 9 ++------- .../src/mediators/InfoPopupMediator.ts | 2 +- .../src/mediators/OptionsViewMediator.ts | 4 ++-- .../src/mediators/PausePopupMediator.ts | 6 +++--- .../src/mediators/ResetConfirmPopupMediator.ts | 9 ++------- games/space-invaders/src/views/IntroView.ts | 5 ++++- games/space-invaders/tsconfig.json | 10 +++++++--- 11 files changed, 30 insertions(+), 36 deletions(-) diff --git a/games/space-invaders/package.json b/games/space-invaders/package.json index 08bbb0f44..5a00de6df 100644 --- a/games/space-invaders/package.json +++ b/games/space-invaders/package.json @@ -29,7 +29,7 @@ "@robotlegsjs/core": "^3.0.0", "@robotlegsjs/pixi": "^3.0.0", "@robotlegsjs/pixi-palidor": "^3.0.0", - "pixi.js": "^5.2.1", + "pixi.js": "^6.3.2", "reflect-metadata": "^0.1.13", "tslib": "^2.3.0" }, diff --git a/games/space-invaders/src/Game.ts b/games/space-invaders/src/Game.ts index 0776115ae..08c7116cd 100644 --- a/games/space-invaders/src/Game.ts +++ b/games/space-invaders/src/Game.ts @@ -1,22 +1,19 @@ -/// - import { Context } from "@robotlegsjs/core"; import { ContextView } from "@robotlegsjs/pixi"; import { PalidorBundle } from "@robotlegsjs/pixi-palidor"; +import { AbstractRenderer, autoDetectRenderer, Container } from "pixi.js"; import { GameConfig } from "./config/GameConfig"; import { PalidorConfig } from "./config/PalidorConfig"; import { ViewsConfig } from "./config/ViewsConfig"; -import PIXI = require("pixi.js"); - export class Game { - private _stage: PIXI.Container; - private _renderer: PIXI.Renderer; + private _stage: Container; + private _renderer: AbstractRenderer; private _context: Context; public constructor() { - this._renderer = PIXI.autoDetectRenderer({ width: 340, height: 480 }); - this._stage = new PIXI.Container(); + this._renderer = autoDetectRenderer({ width: 340, height: 480 }); + this._stage = new Container(); this._context = new Context(); this._context .install(PalidorBundle) diff --git a/games/space-invaders/src/mediators/GameOverPopupMediator.ts b/games/space-invaders/src/mediators/GameOverPopupMediator.ts index cb3be29be..9425fca0d 100644 --- a/games/space-invaders/src/mediators/GameOverPopupMediator.ts +++ b/games/space-invaders/src/mediators/GameOverPopupMediator.ts @@ -13,8 +13,8 @@ export class GameOverPopupMediator extends Mediator { private _gameService: GameService; public initialize(): void { - this.eventMap.mapListener(this.view.homeButton, "click", this._onClickHomeButton, this); - this.eventMap.mapListener(this.view.retryButton, "click", this._onClickRetryButton, this); + this.eventMap.on(this.view.homeButton, "click", this._onClickHomeButton, this); + this.eventMap.on(this.view.retryButton, "click", this._onClickRetryButton, this); } public destroy(): void { diff --git a/games/space-invaders/src/mediators/HUDGameComponentMediator.ts b/games/space-invaders/src/mediators/HUDGameComponentMediator.ts index 6bd705ea3..69986f5ec 100644 --- a/games/space-invaders/src/mediators/HUDGameComponentMediator.ts +++ b/games/space-invaders/src/mediators/HUDGameComponentMediator.ts @@ -18,7 +18,7 @@ export class HUDGameComponentMediator extends Mediator { private _flowService: FlowService; public initialize(): void { - this.eventMap.mapListener(this.view.pauseButton, "click", this.pauseButton_onClick, this); + this.eventMap.on(this.view.pauseButton, "click", this.pauseButton_onClick, this); this.eventMap.mapListener( this.eventDispatcher, GameEvent.UPDATE_HUD_DATA, diff --git a/games/space-invaders/src/mediators/HomeViewMediator.ts b/games/space-invaders/src/mediators/HomeViewMediator.ts index 4a6486329..7df8426aa 100644 --- a/games/space-invaders/src/mediators/HomeViewMediator.ts +++ b/games/space-invaders/src/mediators/HomeViewMediator.ts @@ -9,13 +9,8 @@ export class HomeViewMediator extends Mediator { private _flowService: FlowService; public initialize(): void { - this.eventMap.mapListener(this.view.startButton, "click", this.startButton_onClick, this); - this.eventMap.mapListener( - this.view.optionButton, - "click", - this.optionsButton_onClick, - this - ); + this.eventMap.on(this.view.startButton, "click", this.startButton_onClick, this); + this.eventMap.on(this.view.optionButton, "click", this.optionsButton_onClick, this); } public destroy(): void { diff --git a/games/space-invaders/src/mediators/InfoPopupMediator.ts b/games/space-invaders/src/mediators/InfoPopupMediator.ts index addc590bd..b08993f40 100644 --- a/games/space-invaders/src/mediators/InfoPopupMediator.ts +++ b/games/space-invaders/src/mediators/InfoPopupMediator.ts @@ -9,7 +9,7 @@ export class InfoPopupMediator extends Mediator { private _service: FlowService; public initialize(): void { - this.eventMap.mapListener(this.view.closeButton, "click", this._onClickCloseButton, this); + this.eventMap.on(this.view.closeButton, "click", this._onClickCloseButton, this); } public destroy(): void { diff --git a/games/space-invaders/src/mediators/OptionsViewMediator.ts b/games/space-invaders/src/mediators/OptionsViewMediator.ts index b951b619c..8e36a9a2e 100644 --- a/games/space-invaders/src/mediators/OptionsViewMediator.ts +++ b/games/space-invaders/src/mediators/OptionsViewMediator.ts @@ -9,8 +9,8 @@ export class OptionsViewMediator extends Mediator { private _flowService: FlowService; public initialize(): void { - this.eventMap.mapListener(this.view.homeButton, "click", this._onClickHomeButton, this); - this.eventMap.mapListener(this.view.resetButton, "click", this._onClickResetButton, this); + this.eventMap.on(this.view.homeButton, "click", this._onClickHomeButton, this); + this.eventMap.on(this.view.resetButton, "click", this._onClickResetButton, this); } public destroy(): void { diff --git a/games/space-invaders/src/mediators/PausePopupMediator.ts b/games/space-invaders/src/mediators/PausePopupMediator.ts index 560773b4b..70b30ed87 100644 --- a/games/space-invaders/src/mediators/PausePopupMediator.ts +++ b/games/space-invaders/src/mediators/PausePopupMediator.ts @@ -13,9 +13,9 @@ export class PausePopupMediator extends Mediator { private _gameService: GameService; public initialize(): void { - this.eventMap.mapListener(this.view.homeButton, "click", this._onClickHomeButton, this); - this.eventMap.mapListener(this.view.resumeButton, "click", this._onClickResumeButton, this); - this.eventMap.mapListener(this.view.retryButton, "click", this._onClickRetryButton, this); + this.eventMap.on(this.view.homeButton, "click", this._onClickHomeButton, this); + this.eventMap.on(this.view.resumeButton, "click", this._onClickResumeButton, this); + this.eventMap.on(this.view.retryButton, "click", this._onClickRetryButton, this); } public destroy(): void { diff --git a/games/space-invaders/src/mediators/ResetConfirmPopupMediator.ts b/games/space-invaders/src/mediators/ResetConfirmPopupMediator.ts index 5d430102b..99b63235c 100644 --- a/games/space-invaders/src/mediators/ResetConfirmPopupMediator.ts +++ b/games/space-invaders/src/mediators/ResetConfirmPopupMediator.ts @@ -9,13 +9,8 @@ export class ResetConfirmPopupMediator extends Mediator { private _flowService: FlowService; public initialize(): void { - this.eventMap.mapListener( - this.view.confirmButton, - "click", - this._onClickConfirmButton, - this - ); - this.eventMap.mapListener(this.view.cancelButton, "click", this._onClickCancelButton, this); + this.eventMap.on(this.view.confirmButton, "click", this._onClickConfirmButton, this); + this.eventMap.on(this.view.cancelButton, "click", this._onClickCancelButton, this); } public destroy(): void { diff --git a/games/space-invaders/src/views/IntroView.ts b/games/space-invaders/src/views/IntroView.ts index 36f2718c2..e8a62a7fe 100644 --- a/games/space-invaders/src/views/IntroView.ts +++ b/games/space-invaders/src/views/IntroView.ts @@ -19,7 +19,10 @@ export class IntroView extends Container { } private _setupImages(): void { - const logo: Sprite = TilingSprite.from(AtlasKeys.LOGO_TYPESCRIPT); + const logo: Sprite = TilingSprite.from(AtlasKeys.LOGO_TYPESCRIPT, { + width: 340, + height: 64 + }); logo.anchor.x = 0.5; logo.x = ViewPortSize.HALF_WIDTH; logo.y = ViewPortSize.MAX_HEIGHT - 64; diff --git a/games/space-invaders/tsconfig.json b/games/space-invaders/tsconfig.json index 50dbc28f5..97cd7e708 100644 --- a/games/space-invaders/tsconfig.json +++ b/games/space-invaders/tsconfig.json @@ -8,8 +8,8 @@ /* Module Resolution Options */ "moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */, "types": ["reflect-metadata"] /* Type declaration files to be included in compilation. */, - "allowSyntheticDefaultImports": false /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */, - "esModuleInterop": false /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, + "allowSyntheticDefaultImports": true /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */, + "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, /* Basic Config Options */ "allowJs": false /* Allow javascript files to be compiled. */, "checkJs": false /* Report errors in .js files. */, @@ -39,5 +39,9 @@ "emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */ }, "include": ["./src/**/*.ts"], - "files": ["./node_modules/@robotlegsjs/pixi/definitions/pixi.d.ts"] + "paths": { + "mini-signals": [ + "node_modules/resource-loader/typings/mini-signals.d.ts" /* Loaders needs this to use the more strict mini-signal types */ + ] + } }