How do I add a trigger tile?

Hi there.

I want to add a tile layer for coins and other collectibles that simply has trigger based physics tiles i.e. tiles that will trigger an event when I run through them but, otherwise not react with the player.

I can’t find any property to do that in MTE but, given that triggers are part of Box2D I figure it must be possible otherwise it’s a bit of an oversight isn’t it?

Hello danedwar,

The engine doesn’t provide shortcuts for all possible physics operations or setups, but it does provide the means for users to set these up for themselves. For example, you could create your own property for the tiles you want to make into trigger tiles. Then in your app you create a property listener using mte.addPropertyListener, in which you configure the tile’s physics properties however you like. In MTE property listeners fire when a tile with that property is spawned by the culling system just offscreen.

You can see an example of this in the IsometricStoryboardTMX sample project. The function calls begin at line 176 of scene.lua and the listener events are above at lines 132 - 142. Whenever a tile with a “randomTint” property spawns, the listener event alters its color slightly. Whenever a tile with a “randomSize” property spawns, another event alters the size of the tile slightly. You could easily add a listener for a property named “createTrigger” and place the code for creating the trigger up in its event.

Hello danedwar,

The engine doesn’t provide shortcuts for all possible physics operations or setups, but it does provide the means for users to set these up for themselves. For example, you could create your own property for the tiles you want to make into trigger tiles. Then in your app you create a property listener using mte.addPropertyListener, in which you configure the tile’s physics properties however you like. In MTE property listeners fire when a tile with that property is spawned by the culling system just offscreen.

You can see an example of this in the IsometricStoryboardTMX sample project. The function calls begin at line 176 of scene.lua and the listener events are above at lines 132 - 142. Whenever a tile with a “randomTint” property spawns, the listener event alters its color slightly. Whenever a tile with a “randomSize” property spawns, another event alters the size of the tile slightly. You could easily add a listener for a property named “createTrigger” and place the code for creating the trigger up in its event.