Last active
March 10, 2020 15:15
-
-
Save NoxWings/0f1644089016085aa3d071162f7ec99c to your computer and use it in GitHub Desktop.
highlights PIXI interactive areas
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
function showInteractiveAreas () { | |
const root = APP.safeGetChildByName(""); | |
const debugHitArea = "DebugHitArea"; | |
const queue = [root]; | |
while (queue.length > 0) { | |
const element = queue.pop(); | |
if (element.name === debugHitArea) | |
element.parent.removeChild(element); | |
queue.push(...(element.children || [])); | |
if (!element.interactive) continue; | |
const g = new PIXI.Graphics(); | |
g.alpha = 0.5; | |
g.name = debugHitArea; | |
element.addChild(g); | |
if (element.hitArea) { | |
g.lineStyle(2, 0xFFBD01, 1); | |
g.beginFill(0xC34288); | |
const { x, y, width, height } = element.hitArea; | |
g.drawRect(x, y, width, height); | |
} else { | |
g.lineStyle(2, 0xFFBD01, 1); | |
g.beginFill(0x888888); | |
const { x, y } = element.anchor ? element.anchor : { x: 0, y: 0 }; | |
const { width, height } = element; | |
g.drawRect(-width * x, -height * y, width, height); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment