determineDirection(integer xFrom, integer yFrom, integer xTo, integer yTo)
Determines the direction between two tiles from their raw tile position. E.g x10,y10 is north of x11,y11 and north-east of x10,y11
local qiso = require "plugin.qisoengine"
qiso.setAssetsFolder("assets")
qiso.loadTiledMap("sample-tilemap")
-- Enable the main Qiso loop to render/update our world
qiso.activate()
-- Get the direction of the tapped tile relative to tile 5,5
function tapTile(event)
-- Get the tile located where the screen was tapped. If there is no tile here, getTile returns nil.
local tile = qiso.getTile(event.x, event.y)
if(tile ~= nil) then
print tile.x .. "," .. tile.y .. " is " .. determineDirection(5, 5, tile.x, tile.y) .. " of 5,5"
end
end
-- Do something when the screen is tapped
Runtime:addEventListener('tap', tapTile)