Skip to content

Instantly share code, notes, and snippets.

@Rojoss
Created September 19, 2017 09:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rojoss/9826d7ae53c2a9620c81fc89c32a74c9 to your computer and use it in GitHub Desktop.
Save Rojoss/9826d7ae53c2a9620c81fc89c32a74c9 to your computer and use it in GitHub Desktop.
game.events.subscribe<any>(EventType.DEBUG_COLLISION_BODIES, EventPriorty.NORMAL, (event: Event<messages.debug.ICollisionBodies>) => {
if (GameStage.Instance === undefined) {
return;
}
let color: number;
const graphics: PIXI.Graphics[] = [];
const labels: PIXI.Text[] = [];
let i = 0;
for (const body of event.payload.bodies) {
color = this.colors[this.index % this.colors.length];
this.index++;
const graphic = this.drawCircle(body, color, 0.3);
graphics.push(graphic);
if (i % 5 === 0) {
const label = new PIXI.Text(body.tick.toString(), {
fill: 0xffffff,
fontSize: 32,
align: 'center'
});
label.scale.set(0.25);
label.x = -label.width/2;
label.y = -label.height/2;
graphic.addChild(label);
}
i++;
}
window.setTimeout(() => {
for (const label of labels) {
label.texture.destroy();
label.destroy();
}
for (const graphic of graphics) {
graphic.destroy();
}
}, 5000);
GameStage.Instance.screenshot();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment