I just bought Lime and I’m a newbie to both Corona and Lime. I’m trying to make a simple five-in-a-row game but have encountered a problem I just can’t get my head around. I made a tileset consisting of 3 tiles; a gridshaped tile, an X tile and an O tile. I then made a map in Tiled and filled it entirely with the grid-tile. Next I made a drag and a touch routine so that I could drag the map around and touch the square/grid anywhere to place an X or an O. And here is the problem. I can’t figure out how to place the X/O tile at the given map/grid position where the user touches the screen. I’ve tried different commands like createTileAt, createAndBuildTile, createAndBuildTileAt with no results. I have added the bug-fix to the lime-tile.lua code (http://developer.anscamobile.com/forum/2012/01/03/cant-set-tile-gid), but I still can’t get any tile-manipulating routines to work. (removeTileAt, swapTiles or any of the above) What am I doing wrong and how do I accomplish this. I guess the optimal solution for this problem would be the hopefully? upcoming TileObjects functions, but I still can’t see why I can’t get any of the createTile functions to work.
Here’s the code:
io.output():setvbuf('no')
display.setStatusBar( display.HiddenStatusBar )
local lime = require("lime")
lime.disableScreenCulling()
local map = lime.loadMap("MyMap.tmx")
local visual = lime.createVisual(map)
local onUpdate = function(event)
map:update(event)
end
local onTap = function(event)
local screenPosition = { x = event.x, y = event.y }
local worldPosition = lime.utils.screenToWorldPosition(map, screenPosition)
-- This is where I want my code to go. Something like:
-- map:createAndBuildTileAt(2, "MyTileLayer1", {row = worldPosition.x, column = worldPosition.y} )
-- If I understand this correctly, the 2 (gid) above is the second tile in my tilesheet, which is the X-tile.
end
Runtime:addEventListener("tap", onTap)
local onTouch = function(event)
map:drag(event)
end
Runtime:addEventListener("touch", onTouch)
Runtime:addEventListener("enterFrame", onUpdate)
I would appreciate any help. [import]uid: 129287 topic_id: 22817 reply_id: 322817[/import]