In this post I will explain how you can build interactive objects in HaxeFlixel.
There are 2 great buttons in HaxeFlixel (FlxButton and FlxUIButton), so if you need a standard button you can use them. As I wanted to use a texture from atlas for buttons, I couldn’t use them, so I searched for alternative. Thanks to HaxeFlixel community I got some other way to create buttons in HaxeFlixel. You can’t add event listeners directly to FlxSprite, but you can use flixel.plugin.MouseEventManager for that.
The basic example of using it would be:
You can override these methods for your concrete buttons to react on events. As a big fan of signals I made a button for my project using them.
Now you can listen to a signal from outside. To do that you need to add a listener for the dispatcher:
Also you can make one signal for each event and then listen to it, but I am more used to one listener with event types :)