Jump to content

Call input events explicitly?


spinnerbox
 Share

Recommended Posts

CallEventsExplicitly.png

I have this color picker component which I created on my own. 

The structure of it is as follows: colorPicker is container graphics object which holds one color swatch graphics object(in this case the dark blue) and a button graphics object which has input handler. When i press the button, 13 other color swatch objects are added to colorPicker graphics object. Also when I press the arrow button again it destroys the below color swatch objects. 

However, it  would be good if I can issue a command to remove other color swatches from outside of the colorPicker object, maybe when I press on the other area of the stage.

How can I call existing event in graphics object from outside world? Is there some utility function in Phaser, like call() or?

Link to comment
Share on other sites

On August 26, 2016 at 3:36 AM, spinnerbox said:

How can I call existing event in graphics object from outside world? Is there some utility function in Phaser, like call() or?

I don't think you need to invoke the event, you just need to expose a method and call it.

colorPicker.destroyStuff = function (){
    // …
};

colorPicker.destroyStuff();

some.events.onDown.add(colorPicker.destroyStuff, colorPicker);

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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