MTE 0v980 - https://gum.co/staO
MTE 0v980 will appear in customers’ inboxes shortly! This is a 1.0 release candidate. I will be adding no new features leading up to the final 1.0 release, and I won’t be changing any of the API available in this release, though I won’t rule out minor additions in response to a bug or something I missed.
All sample projects now use TMX maps with CSV layer data encoding. I recommend all developers do the same for the sake of ease of use and performance. Exported Json files are still the smallest and fastest, but each change to the map in Tiled requires exporting the map again. TMX files with CSV encoding are nearly as small and nearly as fast, and they can be directly edited and saved in Tiled, no exporting necessary.
I’ve removed the Tiled Map folders for each sample. Everything you need to open and edit the maps is now integral to each sample’s project folder.
I gave the current documentation a good scrubbing paying particular attention to the API reference document. Additional sample projects, sample code for many of MTE’s functions, and a few tutorials will be coming further down the line. We may also see some thorough tutorials coming from one or more third-party sources, which would just be fantastic!
In the past I’ve treated the Beta as more of an early access program, but at this point I really need developers to report on any problems they encounter! It is time to really polish the engine to a shine! As always you can ask questions, leave feedback, and track engine development progress here on the MTE forum. I’ll be keeping an eye out for bug reports in particular.
Thanks for your support! Please read on for more details on the changes since 0v958.
Updates:
-
It used to be that constraining the camera and then changing the scale of the map would cause the camera constraints to ‘move.’ Even though you had zoomed in, you could not get any closer to the constraint. MTE 0.980 applies constraints continuously, taking into account the scale of the map and it’s rotation.
-
MTE 0.980 calculates the size of the culling region each frame. If you zoom out it will spawn more tiles to fill in the empty screen space. If you zoom in it will cull the tiles no longer visible to improve performance.
-
It is no longer strictly required that users add sprites to the map using addSprite(). Users are now free to add sprites directly to the layer’s group object if they so desire (the engine may automatically insert these sprite’s into a subgroup in certain situations). Furthermore, on orthographic maps the sprites can be moved using transitions and other native Corona SDK calls instead of MTE’s movement functions. Corona’s native transition and translation functions remain between 25% and 50% more efficient than MTE’s movement functions where large numbers of sprites are in motion.
I still recommend using removeSprite() to remove unneeded sprites, rather than doing so directly with object:removeSelf().
-
You can set the engine to update a tiny area of the map around offscreen physics objects by setting their offscreenPhysics property to true. This will allow dynamic physics objects to remain in motion anywhere on the map. Keep in mind that these offscreen areas contribute to the performance demands of your app. You’ll want to keep an eye on how many tiles you have active at any given time.
-
MTE 0.958 and previous versions were hardcoded for a 2:1 Isometric Ratio. Isometric tiles had to be exactly twice as wide as they were tall on the tileset image and in Tiled or the display would be corrupted. MTE 0.980 calculates the Isometric Ratio when the map loads and adjusts accordingly.
API Changes:
-
Calling require(mte) is no longer enough to begin using the engine. You’ll have to create the engine instance as well with the createMTE() function. You can combine both operations into a single line if you like:
local mte = require(“mte”).createMTE()
Or you can keep things seperate:
local mteConstructor = require(“mte”) local mte = mteConstructor.createMTE()
This will also allow you to create additional instances of the engine as needed.
-
The goto() function is gone. It has been replaced with setCamera() to avoid a conflict with future versions of Lua and to more precisely describe what it does.
-
The loadMap() function now returns the map table, not MTE’s masterGroup object.
-
The setCamera() function now returns MTE’s masterGroup object.
-
All functions which took an easing parameter now take a transition parameter. The transition parameter holds an easing function, such as easing.inOutQuad. For example, this is a movement command from 0.958:
mte.moveSpriteTo( { sprite = player, locX = xTile, locY = yTile, time = moveTime, easing = “linear”} )
This is the same function from 0.980:
mte.moveSpriteTo( { sprite = player, locX = xTile, locY = yTile, time = moveTime, transition = easing.linear } )
Because of this the built-in movement functions now support all of Corona’s easing functions.
-
The functions for converting to and from grid coordinates are gone. For example, mte.convert(“gridToLoc”, x, y, layer) and mte.convert(“levelPosToGrid”, x, y, layer) are no longer available. The map’s tile objects are now held in a map.layers[layer].tileObjects table. If you know the location of the tile object you want, you can easily retrieve it from the table without any converting. For example, the tile at 43,56 on layer 3 is stored in map.layers[3].tileObjects[43][56].
-
The convert() function is still available at the moment, but it now calls the new direct conversion functions internally. I recommend switching over to the new functions to avoid performing the string comparison needed by convert(). The conversion functions now work correctly regardless of map scale.
screenToLevelPos(xArg, yArg, layer) screenToLevelPosX(xArg, layer) screenToLevelPosY(yArg, layer) screenToLoc(xArg, yArg, layer) screenToLocX(xArg, layer) screenToLocY(yArg, layer) levelToScreenPos(xArg, yArg, layer) levelToScreenPosX(xArg, layer) levelToScreenPosY(yArg, layer) locToScreenPos(xArg, yArg, layer) locToScreenPosX(xArg, layer) locToScreenPosY(yArg, layer) locToLevelPos(xArg, yArg) locToLevelPosX(xArg) locToLevelPosY(yArg) levelToLoc(xArg, yArg) levelToLocX(xArg) levelToLocY(yArg)
-
The valid values for the ‘kind’ parameter of addSprite are now “sprite”, “imageRect”, “vector”, “group”
-
The constrainCameraToScreen() function is gone. It’s behavior is now the default behavior of constrainCamera().
-
Sprites no longer include the getX(), getY(), getLevelPosX(), and getLevelPosY() functions. The coordinate system of each layer is equal to that of the map. If a tile is 32x32 according to tiled, then it will be 32x32 according to Corona and MTE. If sprite.x = 100, then the sprite is at x = 100 on the tile map as well.
This breaks down at the edge of maps when worldWrap is enabled. As the camera approaches the wrap, sprites on the other side are moved into the camera view so that they are visible across the wrap. In these cases sprite.levelPosX and sprite.levelPosY are equal to the sprite’s position on the map while sprite.x and sprite.y are equal to the sprite’s position on the layer as always.
Isometric maps use an arbitrary coordinate system maintained by the engine. On isometric maps a sprite’s .x and .y parameters will almost never match their level positions. Use sprite.levelPosX and sprite.levelPosY to read their position in relation to the tile map. This is caused by the isometric perspective.