[SOLVED] EventListener for Tilemap

Using the exact same code for adding an event listener to the stage, but instead applying it to a tilemap, it seems like events aren’t being triggered.


stage.addEventListener(MouseEvent.MOUSE_DOWN, function(e) jump = true);


tilemap.addEventListener(MouseEvent.MOUSE_DOWN, function(e) jump = true);

Tilemap behaves like Bitmap, they each extend DisplayObject, but do not extend InteractiveObject (like Sprite does). As a result, you will need to wrap a Tilemap (as you would a Bitmap) inside a Sprite container and listen to that for mouse interaction

You can also listen to the stage too if you want (since it is also an InteractiveObject) depending on how you design your project :slight_smile:

1 Like

I figured it was a failure of understanding the API on my end of things—thank you so much.

It took me a minute to remember why :wink:

1 Like