alestane

Load Specific Terrain

Jan 1st, 2012
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.56 KB | None | 0 0
  1. local sprite = require "sprite"
  2. local terrain = require("terrain")("field.png", 60, {"grass", "dirt", "rock"})
  3.  
  4. return function(size, columns, rows)
  5.     local map = display.newGroup()
  6.     map.Tiles = {}
  7.     for row=-1,rows do
  8.         map.Tiles[row] = {}
  9.         for column=-1,columns do
  10.             local tile = sprite.newSprite(terrain)
  11.             tile:setReferencePoint(display.TopLeftReferencePoint)
  12.             map:insert(tile)
  13.             tile.xScale, tile.yScale = size / tile.width, size / tile.height
  14.             tile.x, tile.y = column * size, row * size
  15.             map.Tiles[row][column] = tile
  16.         end
  17.     end
  18.     return map
  19. end
Advertisement
Add Comment
Please, Sign In to add comment