Author Topic: How to add a mouseEvent on FlxSprites?  (Read 1839 times)


  • New Member
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
How to add a mouseEvent on FlxSprites?
« on: Sun, Oct 11, 2015 »
I'm doing a chess like game, but I can't figure out a practical way to make a menu become visible whenever I click a char and then make it dissapear when I click other tiles, and also make other events trigger based on the buttons (not FlxButtons) I click.

The only one that occurs to me for now is the simple:
if (FlxG.mouse.justPressed())
               if (FlxG.mouse.x >= currentPlayer.x && FlxG.mouse.x < currentPlayer.x + 40 &&
                  FlxG.mouse.y >= currentPlayer.y && FlxG.mouse.y < currentPlayer.y + 40)



  • Member
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
Re: How to add a mouseEvent on FlxSprites?
« Reply #1 on: Tue, Nov 10, 2015 »
If you'd like to have fine tuned control on what sprite you're clicking I'd suggest using PhotonStorm's excellent Flixel Power Tools library and then changing your "piece" class to a FlxExtendedSprite, which can easily accept mouse clicks.

You can find the library here: