Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Remove keyboard callback


Recommended Posts

I have an opening screen to my game where the use can press any key to start.

I implemented this using:

  this.game.input.keyboard.addCallbacks(this, function() {

My problem is that this callback persists over into other states, so if I press any key it always take me back to my Menu state.

I've looked at the Documentation and tried both:

  this.game.input.keyboard.addCallbacks(this, null, null, null);



Neither of which did the trick.

I then simply replaced the callback with:

this.game.input.keyboard.addCallbacks(this, function() {});

Which seems to have solved the problem.

2 questions here:

  1. Is there a cleaner way to do this?
  2. Would having an empty callback like this impact performance in any way?
Link to comment
Share on other sites

  • 4 months later...

  • Recently Browsing   0 members

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