Loading solid tiles into the bump
Now we are going to fetch all the solid tiles/layers and make them respond to collision. We'll do this by the using the
FindSolidTiles()
function; but first we'll load the tiles from Tiled with LoadTiledMap(levelFile)
which will later override map = loader.load()
that we already defined; this is because we want our bumped tiles to load when the tile map loads:
--our tiles are 16x16 sizes, so we should declare the width and height as 16 local tWidth = 16 local tHeight = 16 function LoadTileMap(levelFile) map = loader.load(levelFile) FindSolidTiles(map) --set this to false, will be made true later on. map.drawObjects = false end ---create a table to hold all the solid tiles, you can call it blocks blocks = {} ---from the layer labelled "platform" within tiled, we call the layer and strip out all the tiles, function FindSolidTiles(map) layer = map.layers["platform"] -- get the width and height of each and set them inside the for...