Problem redragging a tile

Hello and thank you for taking the time to answer other people's problems on this forum.

I drag a tile(changing a little things with Graham's help) and set it, and set the tileImage correctly and everything, but the problem is I cant re-drag it again, and I think the problem is that it's not really correctly set, because when I debug, it tells me the tile is set on the grass tileLayer(lower z-index), instead of the base(highest z-index) tileLayer. I dont know if Im explaining myself correctly. Here's the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
--Check if there is a base tile on that position
tmpTile = tileImageLayer:getTileAt( endGridPos )
if not tmpTile then
    tmpTile = tileImageLayer:createAndBuildTileAt( lastGid, endGridPos )
    if not tmpTile then
        print('What is wrong?')
    else
       --it prints tileCreated at layer base, so it should have created and built the tile at the baseLayer
       print("tileCreated at layer " .. tileImageLayer.name)
       tmpTile:show()
    end
else
    print("There is tmpTile")
end

I'm assuming you are then using something like getTileAt on the new tile to be able to drag it? If so that might be where the problem lies.

I set the tile, and the event ends, to re-drag, the user needs to start the event again(the re-drag doesnt happen on the same event call). It should be like a normal drag(with the tile already set on the .tmx by Tiled).

For example, I touch and drag a pre-set tile, drag it to a position where there is no tile of that particular layer. When you lift your finger(event.phase == "ended"), it creates that tile(if there is no tile).

Then on a new event call(I touch with my finger again, but now, on the dynamically set tile), I want it to be able to re-drag(re-position) that tile again, but it doesnt, even though I set it on the base layer and I see the tile image as every other tile image set on that layer, when I debug it prints that it's set on another layer(grass).

views:1603 update:2012/1/10 9:16:25
corona forums © 2003-2011