Skip to content

Commit

Permalink
upgrade pixi.js to v6
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagoschenkel committed May 13, 2022
1 parent 3561952 commit adb5c11
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 36 deletions.
2 changes: 1 addition & 1 deletion games/space-invaders/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
13 changes: 5 additions & 8 deletions games/space-invaders/src/Game.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
/// <reference path="../node_modules/@robotlegsjs/pixi/definitions/pixi.d.ts" />

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)
Expand Down
4 changes: 2 additions & 2 deletions games/space-invaders/src/mediators/GameOverPopupMediator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export class GameOverPopupMediator extends Mediator<GameOverPopup> {
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class HUDGameComponentMediator extends Mediator<HUDGameComponent> {
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,
Expand Down
9 changes: 2 additions & 7 deletions games/space-invaders/src/mediators/HomeViewMediator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@ export class HomeViewMediator extends Mediator<HomeView> {
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 {
Expand Down
2 changes: 1 addition & 1 deletion games/space-invaders/src/mediators/InfoPopupMediator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class InfoPopupMediator extends Mediator<InfoPopup> {
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 {
Expand Down
4 changes: 2 additions & 2 deletions games/space-invaders/src/mediators/OptionsViewMediator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export class OptionsViewMediator extends Mediator<OptionsView> {
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 {
Expand Down
6 changes: 3 additions & 3 deletions games/space-invaders/src/mediators/PausePopupMediator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export class PausePopupMediator extends Mediator<PausePopup> {
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@ export class ResetConfirmPopupMediator extends Mediator<ResetConfirmPopup> {
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 {
Expand Down
5 changes: 4 additions & 1 deletion games/space-invaders/src/views/IntroView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 7 additions & 3 deletions games/space-invaders/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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. */,
Expand Down Expand Up @@ -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 */
]
}
}

0 comments on commit adb5c11

Please sign in to comment.