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:, 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:, null, null, null);


Neither of which did the trick.

I then simply replaced the callback with:, 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?

Share this post

Link to post
Share on other sites

Maybe you could instead use, and nullify it when done with it?

By the way, states have a shutdown() method called when the state is shutdown, so I guess it would be quite clean to nullify the onDownCallback method there.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.