LoginSignup
2
2

More than 5 years have passed since last update.

Pixi.js in Angular

Posted at

Pixi.jsをAngular7で動かす

pixi.jsのインストール

$ npm install --save pixi.js

pixi.jsの型ファイルのインストール

npm install --save @types/pixi.js

angular.jsonの修正

build時にpixi.jsを含めるようにscriptsの配列にPATHを追記する

angular.json
{
  ...
  "projects": {
    "angular7-metronome2": {
      ...
      "architect": {
        "build": {
            "scripts": [
              "node_modules/pixi.js/dist/pixi.min.js"
            ]

Pixi.jsを使う

Pixiを使うコンポネートを作成して、tsファイルに以下のように書き込む

import { Component, OnInit } from '@angular/core';

declare var PIXI: any;

@Component({
  ...
})
export class PcComponent implements OnInit {
  public app: any;

  constructor() {
      this.app = new PIXI.Application({
          width: 800,
          height: 600
      });
  }

  ngOnInit() {
  }

}
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2