FlxG.Keys.pressed not staying true when resetting playstate?

37 views
Skip to first unread message

Jacob Vann

unread,
Nov 29, 2014, 2:10:55 PM11/29/14
to
I looked for official documentation on this, but I did not see anything.  Basically, when I reset the PlayState to load the next room for my player, the FlxG.Keys.pressed values are resetting back to false.  In my game, when the player goes past the edge of the level, the next level is loaded and they are placed in that level with a short fade out/fade in.  My intention is that, if the right or left key are held down, that key will remain held down during the next level loading, and the PlayerObject will see that key is held down and will continue to walk.

However, this is not occurring.  I confirmed with some trace() statements that the FlxG.Keys.pressed.RIGHT and FlxG.Kehys.pressed.LEFT reset to false when the level is loaded, so the player has to quit pressing the key and then press it again to get it to register.

I tried this on both the Mac (c++) build and the Flash build and the behavior is the same.  All of the keys I tried reset to false when the PlayState is reset.  Is this the intended behavior of haxeflixel?  Is there a way to work around this?  Basically, I want to know what keys were being held down the moment the playstate is loaded, but they all say false until a new key is pressed.

Thanks!

Gama11

unread,
Nov 29, 2014, 2:13:53 PM11/29/14
to haxef...@googlegroups.com
All inputs are reset on a state switch. The dev branch has FlxG.inputs.resetOnStateSwitch which you can set to false.

Jacob Vann

unread,
Nov 29, 2014, 6:48:29 PM11/29/14
to haxef...@googlegroups.com
Ok, that's wonderful news.  For now I will stick with the current release and live with the behavior.  It is a minor issue for now but it is good to know that it will be fixed.

-Jacob
Reply all
Reply to author
Forward
0 new messages