webgl-benchmark
Version:
Benchmark WebGL performance using different JavaScript rendering/game engines, such as Pixi and Phaser.
34 lines (28 loc) • 969 B
JavaScript
import IScene from './IScene.js';
export default class BitmapTextStatic extends IScene {
constructor(app, gui) {
super(app, gui);
this.title = 'Text: Bitmap Static';
this.description = 'Text created via the Bitmap Fonts. ';
this.description += 'Advantages: Fastest way to render text. ';
this.description += 'Disadvantages: Cannot change text style dynamically at run time. ';
}
_create(objectCount) {
for (let i = this._children.length; i < objectCount; ++i) {
const text = new PIXI.extras.BitmapText('WebGL', {
font: '35px Desyrel',
align: 'center'
});
if (text.anchor) {
text.anchor.set(0.5);
} else { // for v3
for (let i = 0; i < text.children.length; ++i) {
text.children[i].x -= text.textWidth * 0.5;
text.children[i].y -= text.textHeight * 0.5;
}
}
text.position.set(Math.random() * this._app.screen.width, Math.random() * this._app.screen.height);
this._app.stage.addChild(text);
}
}
}