getTile() Function Reference

getTile(integer x, integer y)

Returns the raw tile co-ordinate of whatever tile is located at the given screen co-ordinate, or returns nil if no tile is at that position. Useful for moving the camera to a tile when clicked, for example.


	local qiso = require "plugin.qisoengine"
	qiso.setAssetsFolder("assets")
	qiso.loadTiledMap("sample-tilemap")

	-- Enable the main Qiso loop to render/update our world
	qiso.activate()

	-- Center on the tapped tile
	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
			qiso.goTo(tile.x, tile.y)
		end
	end

	Runtime:addEventListener('tap', tapTile)