Where do you use it? Because the values in the object are not defined anywhere. Even if defined in the snippet you provided they are out of scope. I mean the w, a, s etc values in the object.
If you say defined in this.__keyList reference them in this.__keys as this.__keyList.w etc.
Thanks, guys. I got it figured out by restoring a backup code I had from a month ago.
Here’s the solution :
This goes inside 'player-states.js' :
const
{
left, right, up,
down, space, shift,
} = this.scene.cursors;
const
{
w, a, s,
d,
} = this.scene.keys;
this.__keys = ({
w : w,
a : a,
s : s,
d : d,
up : up,
down : down,
left : left,
right : right,
space : space,
shift : shift,
});
This goes inside 'player.js' :
this.__keyList =
{
w : Phaser.Input.Keyboard.KeyCodes.W,
a : Phaser.Input.Keyboard.KeyCodes.A,
s : Phaser.Input.Keyboard.KeyCodes.S,
d : Phaser.Input.Keyboard.KeyCodes.D,
}
// Get Keyboard Cursor{s} Input
this.cursors = this.input.keyboard.createCursorKeys ( );
// Get Keyboard Key{s} Input
this.keys = this.input.keyboard.addKeys ( this.__keyList );