I have to admit, your question threw me for a little bit. After giving it some thought and looking into Lime I now see that it comes from some of the differences between how Lime and MTE operate.
Long story short, MTE does not have an equivalent to Lime’s addPropertyListener map event listener, but now that I’ve given it thought I’ve come to realize how very useful it could be. So, I fully intend to add something similar. If possible I’ll have it ready for next week’s MTE update.
In the past my assumption in designing MTE was that developers like yourself would rather create sprites on their own, and then add those sprites to MTE using the addSprite() function. I envisioned developers using Tiled Objects as spawn points, adding them to the map in Tiled and retrieving them by name using getObject(). For example:
--LOAD SPAWN local playerSpawn = mte.getObject({name = "playerSpawn"}) --CREATE PLAYER SPRITE ------------------------------------------------------------ local spriteSheet = graphics.newImageSheet("spriteSheet.png", {width = 32, height = 32, numFrames = 96}) local sequenceData = { {name = "up", sheet = spriteSheet, frames = {85, 86}, time = 400, loopCount = 0}, {name = "down", sheet = spriteSheet, frames = {49, 50}, time = 400, loopCount = 0}, {name = "left", sheet = spriteSheet, frames = {61, 62}, time = 400, loopCount = 0}, {name = "right", sheet = spriteSheet, frames = {73, 74}, time = 400, loopCount = 0} } local player = display.newSprite(spriteSheet, sequenceData) local setup = { kind = "sprite", layer = playerSpawn[1].layer, levelPosX = playerSpawn[1].x, levelPosY = playerSpawn[1].y, levelWidth = 32, levelHeight = 32 } mte.addSprite(player, setup) mte.setCameraFocus(player)
You could store all the parameters you need in the Tiled Object’s properties just as you would in a tile’s properties. The resulting code is not much different than the Lime equivalent. The primary difference is that the Lime equivalent is triggered as Lime creates the world, while the MTE code is executed by you, anytime after MTE loads the map.
You can retrieve the display objects of individual tiles using getTileObj(), however it is important to keep in mind that whereas Lime builds the entire map, MTE only builds that part of the map visible onscreen. This is the culling mechanism responsible for MTE’s superior speed. Offscreen tiles don’t exist in the same sense as onscreen tiles, they do not have a display object for you to retrieve.
Feel free to ask if you have other questions or need further explanation, and keep in mind that the Million Tile Engine is a Beta product subject to change and improvement as customer feedback comes in.