Skip to content

Instantly share code, notes, and snippets.

@gltovar
Created November 14, 2017 02:38
Show Gist options
  • Save gltovar/23f47d0c81c33a9ca6d24ae5ac32df20 to your computer and use it in GitHub Desktop.
Save gltovar/23f47d0c81c33a9ca6d24ae5ac32df20 to your computer and use it in GitHub Desktop.
fix for flx button JUST_PRESSED/RELEASED states when polling
///// HOW IT IS NOW
/**
* Called by the game loop automatically, handles mouseover and click detection.
*/
override public function update(elapsed:Float):Void
{
super.update(elapsed);
input.update(); ////////// problem method
if (visible)
{
// Update the button, but only if at least either mouse or touches are enabled
#if FLX_POINTER_INPUT
updateButton();
#end
// Trigger the animation only if the button's input status changes.
if (lastStatus != status)
{
updateStatusAnimation();
lastStatus = status;
}
}
}
///// PROPOSED SOLUTION
/**
* Called by the game loop automatically, handles mouseover and click detection.
*/
override public function update(elapsed:Float):Void
{
super.update(elapsed);
if (visible)
{
// Update the button, but only if at least either mouse or touches are enabled
#if FLX_POINTER_INPUT
updateButton();
#end
// Trigger the animation only if the button's input status changes.
if (lastStatus != status)
{
updateStatusAnimation();
lastStatus = status;
}
}
input.update(); ////////// move this down here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment