I’ve got it working like this:
[lua]
local myMap=CoronaTiled.load(“demo.json”)
myMap.draw([layer], x1,y1, x2,y2)
–myMap.drawAll()
–myMap.erase([layer], x1,y1, x2,y2)
–myMap.eraseAll([layer])
myMap.tilePhysics([layer]) – Updates tile physics for the map, or for a single layer; physics properties are added via Tiled
myMap.objPhysics([layer]) – Updates obj physics for the map, or for a single layer; physics properties are added via Tiled
[/lua]
And then I have a new type of object - “listener” - that you create by making a 0x0 rectangle in Tiled, giving it a “listener” attribute, and loading the map. Then you can do things like this:
[lua]
–You have a “listener” object with “listener” attribute == “playerSpawned”
local function spawnPlayer(event)
--Values for the event include “event.time”, “event.x”, “event.y”, “event.name” and I’ll probably add any properties the user adds in Tiled
--spawn player at event.x,event.y
end
Runtime:addEventListener(“playerSpawned”, spawnPlayer)
myMap.executeListener(“playerSpawned”)
–myMap.executeListeners() – Executes any listeners you’ve created
[/lua]
Sound good?
C