Jump to content

Persist keyboard events between states


GameDemon
 Share

Recommended Posts

Is it possible to persist keyboard events between states? I am setting one with `game.input.keyboard.addKey()` and `myKey.onUp.add()` in the first state `create` function, but changing states seems to remove the listener.

 

I'm using 2.4.4, but can't find the documentation for what occurs between state transitions, is this available somewhere?

 

Thanks in advance

Link to comment
Share on other sites

I'd love to hear other people chime in but here's what I do (not authoritative! not a best practice or anything! just what works for me!)

 

If it's something that needs to be a part of the update or render cycle I make a Phaser.Plugin. Anything that manages tweens, or ensures timings between events, even particle effects, that kind of thing... I tend to make those Plugins. Most of those plugins make themselves properties of the game instance.

 

If it's just a collection of stuff that would be handy to reference elsewhere I make an object and stick it on the game instance, too.  For example, every layer in my game is hung off a "groups" property on the game instance.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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