Jump to content

Input system setCapture/releaseCapture support?

Brad P. Taylor

Recommended Posts

Hello Everyone,


This is a question, possible answer and a feature request all rolled into one.


First the question:


For my UI I need a way to set a specific sprite (or set of sprites) to be the only ones with active inputHandlers, Basically setCapture/releaseCapture... I spent a fair amount of time looking over the input system and didn't see this feature? 


My 'answer'




This code adds setCapture, releaseCapture and getCapture to the Phaser.Input class.


setCapture takes a single inputHandler or an array of them and will push the currently active notion of interactiveItems making the arguments the current set of interactive elements. The releaseCapture method restores things to the state before the push and of course getCapture returns the inputHandlers that have captured input.


The feature request


My hack works enough for now, but it seems clunky and woe to me if I ever need enable/disable sprite inputs while inside a capture mode. A more robust event bubbling system for sprites (and groups), would be really handy.  I know this isn't a trivial request but it would probably make things easier for making certain types of UI.







Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...