Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local sprite = require "sprite"
- local terrain = require("terrain")("field.png", 60, {"grass", "dirt", "rock"})
- return function(size, columns, rows)
- local map = display.newGroup()
- map.Tiles = {}
- for row=-1,rows do
- map.Tiles[row] = {}
- for column=-1,columns do
- local tile = sprite.newSprite(terrain)
- tile:setReferencePoint(display.TopLeftReferencePoint)
- map:insert(tile)
- tile.xScale, tile.yScale = size / tile.width, size / tile.height
- tile.x, tile.y = column * size, row * size
- map.Tiles[row][column] = tile
- end
- end
- return map
- end
Advertisement
Add Comment
Please, Sign In to add comment