-
-
Save Rojoss/9826d7ae53c2a9620c81fc89c32a74c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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