MTE v0.872 - http://gum.co/staO
The Million Tile Engine’s horizon is ever-expanding as more and more features fall into place! Version 0.872 marks the end of the heavy lifting for Physics integration and brings a slew of new improvements, features, and functionality to the engine. With the bulk of the physics work out of the way I’ll be setting my sights on the next major feature: isometric support.
The most visually obvious addition in 0.872 is support for the remaining Tiled Objects; polygons, polylines, ellipses, and box/squares. All these objects can be rendered as vector objects by setting any combination of lineColor, fillColor, and lineWidth properties in the Tiled editor. You can define their physics properties as you would with the gid/tile objects of 0.844, but the new engine goes one step further: by setting an object’s shape property to “auto” you can have the correct physics shape generated for you at runtime. This includes multi-body shapes for convex polygons; draw any non-intersecting polygon in Tiled and MTE will find a combination of bodies to fill that space and make it collidable!
Tiled Objects are drawn en masse with the new function drawObjects(). If you gave the object a name in Tiled, the new display object will also have that name, and you will be able to call up a reference to that specific display object as needed. Additionally developers can draw a single object using drawObject(), or redraw an object with modified properties by calling redrawObject().
I touched on a few of the other new features in the forum. When you load a map, that map is now saved in memory by default. The next time you call loadMap(), that map will load from memory in a fraction of the time, rather than having to be parsed from it’s file all over again. New ‘unload’ arguments for cleanup() and loadMap() will override this feature and erase the map, perfect for conserving memory. The brand new functions preloadMap(), getLoadedMaps(), and unloadMap() allow for greater control over what map is available and when.
New lookup functions make life amongst large numbers of sprites and tiles a lot easier! The function getSprites() takes many parameters and returns a convenient list of all sprites which match those parameters. getTilesWithProperty() does exactly what it says, returning every active tile with the matching property.
More intriguing are the new listener functions. addPropertyListener() monitors the engine’s internal clockwork for spawning tiles into the active culling region. If a tile generates which has the specified property, the engine dispatches an event to your listener. The function addObjectDrawListener() works in much the same way, however it monitors the Tiled Object draw functions mentioned above and dispatches an event on a matching name rather than a property.
There is much new to see! I recommend looking into the Platformer - Angled PHYSICS sample project. It includes a new map demonstrating the new Tiled Object physics and draw support, toggle-able by uncommenting lines in main.lua. The new LineOfSight sample demonstrates the possibilities of Physics Raycasting for obstacle detect and the sample’s namesake; line of sight. Definitely take a few moments to peruse the new API and Reserved Tiled Properties documentation as well.
A great deal has changed within the pre-existing MTE functions to improve stability and performance, and to enable MTE’s old movement functions to manipulate physics objects. If I’ve learned anything, it is that bugs love change! I’ll be keeping an eye on the forum for any bug reports.
Enjoy!