I was just wondering if it’s possible to drag a display group on an isometric map( being able to keep dragging a single tile ). I’ve tried in some ways, without success. I imagine it’s possible, but I thought about asking here first, so I dont work through a really long and hard path just to find out it was a lot simpler.
So I was thinking something like this:
--...
local startGridPos = nil
local onMapClick = function( event )
if not startGridPos then
startGridPos = \_functions.screenToGridPosition(event)
end
local tile = \_functions.getTileFromScreen(startGridPos)
tileGid = tile.gid
tile:drag( event )
tile:getVisual():toFront()
if event.phase == 'began' then
if tile then
local gidImg = \_functions.\_gidImage(tileGid)
--Get the tile image gid and check if the tile is a grass tile(equivalent to an empty tile)
if \_functions.\_isGrassTile(tileGid) then
--It would continue the rest of the onMapClick function normally(changing the image gid to an tree and dragging it or something like that) and inserting the tile to the display group
else
--tileGroup is the display group previously defined
tileGroup:drag( event )
end
end
Runtime::addEventListener("touch", onMapClick)
I dont know if I explained my point correctly. Hope that I did, I can post more code if needed, thank you before hand for even checking this post to help [import]uid: 109816 topic_id: 19550 reply_id: 319550[/import]