Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onUp(pointer) {
const { navMesh, spriteGroup } = this;
const isRightButton = pointer.rightButton.isDown;
const { withinGame, worldX, worldY } = pointer;
const paths = [];
if (!withinGame || !isRightButton || !navMesh) {
return;
}
const destination = new Point(worldX, worldY);
spriteGroup.forEachAlive(sprite => {
const { position, width, height } = sprite;
const size = Math.max(width, height);
const path = navMesh.getPath(position, destination, size);
// If no path found, do nothing with the sprite
if (!path) {
return sprite.addPath([]);
}
paths.push(path);
sprite.addPath(path);
}, this);
this.renderPaths(paths);
}