replaceInTile() Function Reference

replaceInTile(x, y, frame, replacement)

Replaces a specific frame within a tile. Useful for example, to open and close doors by swapping out their sprites.

	local qiso = require "plugin.qisoengine"

	-- Enable the main Qiso loop to render/update our world

	-- Replaces any floorboard layers that might be on the tapped tile to flip their direction.
	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
			-- 5, 6, 7 and 8 are the tileset frames used in our sample map for floorboards.
			qiso.replaceInTile(tile.x, tile.y, 7, 8)
			qiso.replaceInTile(tile.x, tile.y, 6, 7)
			qiso.replaceInTile(tile.x, tile.y, 5, 6)

	-- Do something when the screen is tapped
	Runtime:addEventListener('tap', tapTile)