Controller/Scene Issue

My 2D platformer game is set up where each sector is its own scene. When the player walks beyond the far right edge of scene 1, he ends up at the left edge of scene 2 (like in Metroid and Castlevania games). The problem I’m having is that for each scene, when it’s loaded for the first time, it seems the game doesn’t recognize the controller until a new input is pressed.

For example, I start the game and hold right in scene 1. When I reach the edge and scene 2 is loaded, I’m still holding right on the left control stick, but the player is in idle state, as if nothing is being pressed. Then as soon as I press any button (or move the control stick angle by any amount), the game recognizes the controller and the player goes back to the run state.

The same is true if I am holding left or right as I load the game for the first time, the player just stands there, even though I’m holding a direction.

Any ideas for what I can do to get around this? Players will be annoyed if the character stands still while they hold a direction.

Keyboard or gamepad?

Gamepad. Forgot to specify.

Two points.

  • games like Metroid/Castlevania shouldn’t change scenes when player is out of the “screen”.

Use scenes for each “big areas” ( like the cd rooms of Castlevania and the elevators rooms in Metroid)

You can set world bounds and set the camera position when the players is out of the screen.

  • when you need change the scene, preserve the player and the cursor between them.

My scenes would be too big if I used them for each “big area”, it would also be a huge structural change.

I tried preserving the gamepad across scenes by setting it as a property, that didn’t work. When I change scenes the controller just stops responding, as if it needs to be re-initialized each time a scene is loaded. Here’s how I initialize it: = this.scene.input.gamepad.gamepads[0]

Is there any way to initialize it without using “scene.input”?
Why can’t the game recognize the controller until a new input is pressed after the scene starts?
Why can’t it just tell that the player is holding left or right from the start?

Try multiple activate scenes at the same time.

scene.scene.launch(key, data)

See this example

Register gamepad at a scene, get this scene back at other scene (scene.scene.get(key))

Don’t do this.

I think the gamepads are supposed to be refreshed each time a scene starts. Use the latest Phaser if not already.

Actually, the same thing happens with the keyboard. I walk into a new scene and the character stands there while I’m holding the left or right key. I logged it and the game recognizes the key as not being pressed in that moment. It’s completely intermittent with the keyboard though, sometimes it recognizes it as being pressed, sometimes it doesn’t.

UPDATE: I found a workaround for the keyboard version of this issue. I just manually set the value of whether the key is down or not based on whether or not it was in the previous scene.