These are chat archives for pixijs/pixi.js

6th
Nov 2018
weepy
@weepy
Nov 06 2018 16:14
Hi I'm trying to hook in to the PIXI ticker so I can use Mr Doob's Stats to measure performance
Is it possible to use with PIXI.Application . ?
ayeQ
@ayeQ
Nov 06 2018 17:39

Hi Weepy,
Maybe this class of mine will give you insight to using the ticker. PIXI.Application is used to setup the canvas. Ticker is static.
import * as PIXI from 'pixi.js';
import { TweenMax, Power1 } from "gsap/all";
import { Pumpkin } from "./Pumpkin";

export class PumpkinContainer extends PIXI.Container {
constructor(pixiCanvas){
super();
this.pumpkins = new Array();
this.pixiCanvas = pixiCanvas;
}
render(){
for(var i=0;i<1;i++){ this.pumpkins.push(new Pumpkin()); this.addChild(this.pumpkins[i]); } TweenMax.ticker.addEventListener("tick", () => this.update());
}
update(){
TweenMax.to(this, .5, {
pixi: {
x: this.pixiCanvas.xPointer,
y: this.pixiCanvas.yPointer,
alpha: .4
},
ease: Power1.easeOut
});
}
}

weepy
@weepy
Nov 06 2018 21:06
i understand the ticker
it's that i want to wrap the stage rendering in stats.begin() and stats.end() calls so that the Stats package can measure how long it takes
weepy
@weepy
Nov 06 2018 21:23

I ended doing :

 // monkey patch
pixiApp._render = pixiApp.render
pixiApp.render = () => {
  stats.begin()
  pixiApp._render()
  stats.end()
}

Not sure if there's a better way ?