Hello,
Ok let’s go …
extract package.json
“dependencies”: {
"@angular/common": “2.0.0”,
"@angular/compiler": “2.0.0”,
"@angular/compiler-cli": “0.6.2”,
"@angular/core": “2.0.0”,
"@angular/forms": “2.0.0”,
"@angular/http": “2.0.0”,
"@angular/platform-browser": “2.0.0”,
"@angular/platform-browser-dynamic": “2.0.0”,
"@angular/platform-server": “2.0.0”,
"@ionic/storage": “1.0.3”,
"@types/fpsmeter": “^0.3.28”,
"@types/lodash": “^4.14.37”,
"@types/pixi.js": “^3.0.30”,
"@types/stats": “^0.16.30”,
“fpsmeter”: “^0.3.1”,
“ionic-angular”: “2.0.0-rc.1”,
“ionic-native”: “2.2.3”,
“ionicons”: “3.0.0”,
“lodash”: “^4.16.4”,
“nipplejs”: “^0.6.7”,
“pixi.js”: “^4.1.0”,
“rxjs”: “5.0.0-beta.12”,
“stats.js”: “^0.16.0”,
“zone.js”: “0.6.21”
},
“devDependencies”: {
"@ionic/app-scripts": “0.0.37”,
“typescript”: “^2.0.3”
}, …
home.html
<ion-content>
<div #canvas></div>
</ion-content>
home.ts
import { Component, ViewChild } from ‘@angular/core’;
import { NavController } from ‘ionic-angular’;
import { Content } from ‘ionic-angular’;
import * as Stats from ‘Stats.js’; //optionnal : it’s for display framerate
import * as PIXI from ‘pixi.js’;
@Component({
selector: ‘page-home’,
templateUrl: ‘home.html’
})
export class HomePage {
@ViewChild(Content) content: Content;
public vPadData : any;
hello: String = “hello world”;
canvas:any ;
constructor(public navCtrl: NavController) {}
ngAfterViewInit() {
PIXI.autoDetectRenderer(800, 600, {backgroundColor: 0x1099bb});
var renderer = PIXI.autoDetectRenderer(800, 600,{backgroundColor : 0x1099bb});
this.content.getNativeElement().appendChild(renderer.view);
//this.canvas.nativeElement.appendChild(renderer.view);
//console.log(renderer.view);
// create the root of the scene graph
var stage = new PIXI.Container();
// create a texture from an image path
// var texture = PIXI.Texture.fromImage('assets/basics/bunny.png');
// create a new Sprite using the texture
let bunnies = [];
for (var j = 0; j < 5; j++) {
for (var i = 0; i < 5; i++) {
var bunny = PIXI.Sprite.fromImage('assets/basics/bunny.png');
bunny.anchor.x = 0.5;
bunny.anchor.y = 0.5;
bunny.x = 40 * i + 100;
bunny.y = 40 * j + 200;
stage.addChild(bunny);
bunnies.push(bunny);
};
};
var me = PIXI.Sprite.fromImage('assets/basics/bunny.png');
me.anchor.x = 0.5;
me.anchor.y = 0.5;
me.x = 20;
me.y = 20;
stage.addChild(me);
// init stats
let stats = new Stats();
stats.showPanel(0); // 0: fps, 1: ms, 2: mb, 3+: custom
this.content.getNativeElement().appendChild(stats.dom);
let page = this;
// start animating
animate();
function animate() {
stats.begin();
requestAnimationFrame(animate);
// just for fun, let's rotate mr rabbit a little
for (let bunny of bunnies) {
bunny.rotation += 0.1;
}
// render the container
renderer.render(stage);
stats.end();
}
}
}
I hope it’s help you
Best regards