I'm trying to draw lines between nodes on a map. I'm not sure why, but I can't get the lines to show. Can someone tell me what I'm doing wrong? Neither me nor chat gpt can diagnose the issue. [Edit: this code was *not* generated by ChatGPT. I just use it as a helper when I get stuck because while the code it makes is generally useless, it does sometimes catch human errors that I overlook. It's suggestions never work, but at least it points out what I mistyped or where I threw in a circular reference.]
The code works as such:
I've verified in console that the Coords are all valid, alpha is at 1, zIndex is impossibly high, and it's included in the scene
And the LTS_Node that appears in the list of children on the Scene *IS* being displayed. Can anyone tell me what's going wrong here and how I fix it? I just want to draw some lines connecting some clickable sprites 🙁
The code works as such:
JavaScript:
calculateNodeConnections() {
for (const nodeID in Pockets.LTS.nodesList) {
const node = Pockets.LTS.nodesList[nodeID];
if (node && node.unlocked) {
for (const connectedNodeID of node.connectedNodes) {
const connectedNode = Pockets.LTS.nodesList[connectedNodeID];
if (connectedNode && connectedNode.unlocked) {
const key = `${node.nodeID}-${connectedNodeID}`;
const reverseKey = `${connectedNodeID}-${node.nodeID}`;
// Check if the connection or its reverse already exists
if (!this._nodeConnections[key] && !this._nodeConnections[reverseKey]) {
const line = new PIXI.Graphics();
this.addChild(line);
line.lineStyle(20, 0xFFFFFF, 1); // Change line style as needed
line.moveTo(node.xCoord, node.yCoord);
line.lineTo(connectedNode.xCoord, connectedNode.yCoord);
line._zIndex = 9999;
this._nodeConnections[key] = line;
}
}
}
}
}
}
And the LTS_Node that appears in the list of children on the Scene *IS* being displayed. Can anyone tell me what's going wrong here and how I fix it? I just want to draw some lines connecting some clickable sprites 🙁