Thanks Dyson, that makes sense. My map isnt huge so dont think it will be a problem, but doing this breaks my scroll on touch on the map. Heres an example, my block scale is 30 so i made it 15 and zoomed in
display.setStatusBar(display.HiddenStatusBar); -- lime = require("lime.lime") local mte = require ("mte") system.activate("multitouch") --LOAD MAP ----------------------------------------------------------------------------- mte.loadMap("pluto") mte.goto({locX = 1, locY = 24, blockScale = 15}) mte.constrainCameraToScreen({ edges = {true, true, true, true}, time = 50 }) mte.zoom(2, 1) local mapObj = mte.getMapObj() local scaleFactor = mte.blockScaleX / mte.worldScaleX --The ratio of the blockScale to the native size of your tiles, necessary for touch scrolling local startX, startY, currentX, currentY local isDragging -- print(scaleFactor) local onUpdate = function( event ) -- Update the map. Needed for using map:setFocus() if isDragging then mte.moveCamera((startX - currentX) / scaleFactor / mapObj.xScale, (startY - currentY) / scaleFactor / mapObj.yScale) startX = currentX startY = currentY end mte.update() mte.debug() end local function calculateDelta( previousTouches, event ) local id,touch = next( previousTouches ) if event.id == id then id,touch = next( previousTouches, id ) assert( id ~= event.id ) end local dx = touch.x - event.x local dy = touch.y - event.y return dx, dy end -- create a table listener object for the bkgd image function mapObj:touch( event ) local result = true local phase = event.phase local previousTouches = self.previousTouches local numTotalTouches = 1 if ( previousTouches ) then -- add in total from previousTouches, subtract one if event is already in the array numTotalTouches = numTotalTouches + self.numPreviousTouches if previousTouches[event.id] then numTotalTouches = numTotalTouches - 1 end end if "began" == phase then if numTotalTouches == 1 then startX = event.x startY = event.y currentX = event.x currentY = event.y isDragging = true end -- Very first "began" event if ( not self.isFocus ) then -- Subsequent touch events will target button even if they are outside the stageBounds of button display.getCurrentStage():setFocus( self ) self.isFocus = true previousTouches = {} self.previousTouches = previousTouches self.numPreviousTouches = 0 elseif ( not self.distance ) then local dx,dy if previousTouches and ( numTotalTouches ) \>= 2 then dx,dy = calculateDelta( previousTouches, event ) end -- initialize to distance between two touches if ( dx and dy ) then local d = math.sqrt( dx\*dx + dy\*dy ) if ( d \> 0 ) then self.distance = d self.xScaleOriginal = self.xScale self.yScaleOriginal = self.yScale -- print( "distance = " .. self.distance ) end end end if not previousTouches[event.id] then self.numPreviousTouches = self.numPreviousTouches + 1 end previousTouches[event.id] = event elseif self.isFocus then if "moved" == phase then if numTotalTouches == 1 then currentX = event.x currentY = event.y end if ( self.distance ) then local dx,dy if previousTouches and ( numTotalTouches ) \>= 2 then dx,dy = calculateDelta( previousTouches, event ) end if ( dx and dy ) then local newDistance = math.sqrt( dx\*dx + dy\*dy ) local scale = newDistance / self.distance -- print( "newDistance(" ..newDistance .. ") / distance(" .. self.distance .. ") = scale(".. scale ..")" ) if ( scale \> 0 and self.xScaleOriginal \* scale \<= 2 and self.xScaleOriginal \* scale \>= 1) then self.xScale = self.xScaleOriginal \* scale self.yScale = self.yScaleOriginal \* scale end end end if not previousTouches[event.id] then self.numPreviousTouches = self.numPreviousTouches + 1 end previousTouches[event.id] = event elseif "ended" == phase or "cancelled" == phase then if numTotalTouches == 1 then startX, startY, currentX, currentY = nil, nil, nil, nil isDragging = false end if previousTouches[event.id] then self.numPreviousTouches = self.numPreviousTouches - 1 previousTouches[event.id] = nil end if ( #previousTouches \> 0 ) then -- must be at least 2 touches remaining to pinch/zoom self.distance = nil else -- Allow touch events to be sent normally to the objects they "hit" display.getCurrentStage():setFocus( nil ) self.isFocus = false self.distance = nil self.xScaleOriginal = nil self.yScaleOriginal = nil -- reset array self.previousTouches = nil self.numPreviousTouches = nil end end end return result end Runtime:addEventListener( "enterFrame", onUpdate ) mapObj:addEventListener( "touch", mapObj ) --Touch listener for touch scroll and pinch zoom