IgeTileMap2d mouse events fire before all others?

All things HTML5 or text based engines, or really any web based engines.
Post Reply
foolmoron
Posts: 25
Joined: Wed Sep 11, 2013 3:34 pm

IgeTileMap2d mouse events fire before all others?

Post by foolmoron »

So I've noticed that the mouse events for a TileMap2d (mouseDown, mouseUp, mouseMove) are fired during the TileMap2d's tick function, which is called during IgeEntity.renderSceneGraph. All other input events are fired through the IgeInputComponent's tick, which is called after all the render ticks. Is this intentional?

I'm getting two unwanted side-effects from this:
1. TileMap2d mouse events always occur, and are always first
2. I can't stop the propagation of input events from a TileMap2d mouse event handler

This makes it pretty annoying when I have a clickable button over a clickable tile map and I want the button to eat the mouse event. Or am I missing something and/or doing something wrong?
signature
User avatar
coolbloke1324
Posts: 181
Joined: Mon Jan 23, 2012 5:20 pm

Re: IgeTileMap2d mouse events fire before all others?

Post by coolbloke1324 »

foolmoron wrote:So I've noticed that the mouse events for a TileMap2d (mouseDown, mouseUp, mouseMove) are fired during the TileMap2d's tick function, which is called during IgeEntity.renderSceneGraph. All other input events are fired through the IgeInputComponent's tick, which is called after all the render ticks. Is this intentional?

I'm getting two unwanted side-effects from this:
1. TileMap2d mouse events always occur, and are always first
2. I can't stop the propagation of input events from a TileMap2d mouse event handler

This makes it pretty annoying when I have a clickable button over a clickable tile map and I want the button to eat the mouse event. Or am I missing something and/or doing something wrong?
Hey ya,

Yes, tilemaps are TRICKY! The reason for the mouse events being handled directly by the map is that tilemaps are effectively infinite. They have no width or height or any real bounds at all. With this in mind, the engine is unable to detect if a mouse click was *inside* a map's axis-aligned bounding box because the box has no dimensions.

You can see the dilema... if you use standard entity mouse hit detection it requires a bounding box but the bounds are infinite. I guess there might be a way around that but I'm not sure.
CEO & Lead Developer
Irrelon Software Limited
http://www.isogenicengine.com
foolmoron
Posts: 25
Joined: Wed Sep 11, 2013 3:34 pm

Re: IgeTileMap2d mouse events fire before all others?

Post by foolmoron »

Makes sense.

Although in my case, the clickable area of the tile map is bounded, so I guess I'll just use an auxiliary entity overlayed on top to handle the mouse events.

Edit: Just tried the above solution and it works beautifully. Mount an isometric entity to the tile map and set its bounds using size3d to whatever clickable bound you want (with a height of 0 so that it is sorted under all other mounted entities). Translate it so that it aligns properly with the tile map (because its default origin is in the center of the object). Then you can add whatever mouse events you want to the entity and it will behave as you would expect, using IgeInputComponent. You can still reference the parent tile map to use mouseToTile and other functions, so it's a pretty seamless interface.
signature
Post Reply

Return to “HTML5/Web Engines”