我尝试使用 pixi.js 和 ang18 制作简单的应用程序。
import { Component, OnInit } from '@angular/core';
import * as PIXI from 'pixi.js';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
// app!: PIXI.Application;
title = 'game';
constructor() {}
ngOnInit(): void {
const app = new PIXI.Application();
let type = "WebGL";
if (!PIXI.isWebGLSupported()) {
type = "canvas";
}
//Add the canvas that Pixi automatically created for you to the HTML document
document.body.appendChild(app.canvas);
PIXI.sayHello('HELLO');
}}
编译很好,但我得到了空白页。请帮我找到答案:为什么我看不到 HELLO 文本。
实例化 PIXI.Application 类后,您需要“初始化”应用程序
await app.init();
不见了。
-https://pixijs.download/release/docs/index.html