1
PIXI.jsを使用して円を描画するクラスを作成しようとしています。Pixi.js v4とTyperscript(IONIC 2)を使用して円を描く
これは私のhome.tsクラス
import { Component, ViewChild, ElementRef } from '@angular/core';
import { NavController } from 'ionic-angular';
import { CanvasAnimations } from '../../canvas/Canvas'
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
canvas = new CanvasAnimations();
@ViewChild('canvasWrapper') MyCanvas:ElementRef;
@ViewChild('homeContent') HomeContent:ElementRef;
constructor(public navCtrl: NavController) {}
ionViewDidLoad() {
this.canvas.setCanvas(this.MyCanvas, window.innerWidth, window.innerHeight);
this.canvas.generateCircle();
}
}
と私はキャンバスがレンダリングではなく、円と、私は理由を理解していないされて見ることができますしかし、これは私のCanvasAnimationsクラス
import { ElementRef } from '@angular/core';
import * as PIXI from 'pixi.js';
export class CanvasAnimations {
// Class Properties
stage = new PIXI.Container();
constructor() { }
setCanvas(canvasElement: ElementRef, windowWidth: number, windowHeight: number) {
var renderer = PIXI.autoDetectRenderer(windowWidth, windowHeight, { backgroundColor: 0x00FF00, antialias: true });
canvasElement.nativeElement.appendChild(renderer.view);
renderer.render(this.stage);
}
generateCircle() {
var circle = new PIXI.Graphics();
circle.beginFill(0x000000);
circle.drawCircle(0, 0, 100);
circle.endFill();
circle.x = 100;
circle.y = 130;
this.stage.addChild(circle);
}
}
です.. 助言がありますか?