Advertisement
alestane

Map adjustment

Apr 24th, 2012
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.45 KB | None | 0 0
  1. local startX, startY, mapX, mapY
  2. local function dragMap(event)
  3.     self = event.target
  4.     if event.phase == "began" then
  5.         startX, startY = self.viewX, self.viewY
  6.         mapX, mapY = self.x, self.y
  7.     elseif actor == nil and event.phase == "moved" then
  8.         local dX, dY = event.x - event.xStart, event.y - event.yStart
  9.         self:View(startX + math.floor(dX / size), startY + math.floor(dY / size))
  10.         self.x, self.y = (mapX + dX) % size, (mapY + dY) % size
  11.     end
  12. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement