davidfig / pixi-viewport

A highly configurable viewport/2D camera designed to work with pixi.js
https://davidfig.github.io/pixi-viewport/
MIT License
1.04k stars 174 forks source link

Detect clicks to 'blank' viewport? #396

Open deklanw opened 2 years ago

deklanw commented 2 years ago

I'm trying to detect clicks to the viewport which don't intersect with any interactive objects in order to get the "click blank space to reset state" effect.

For regular Pixi cases without this library I see people are creating a sprite that fills the background and detecting clicks on that. https://stackoverflow.com/a/63201945

But, when I try that trick with pixi-viewport I just get a sprite of fixed size when I zoom. Is there a way to do this without creating a background sprite and resizing it on every moved event?

davidfig commented 2 years ago

There's a clicked event in pixi-viewport that will trigger on a click anywhere on the viewport.