how to drag -> scroll

Hi,

Please I like to know if somebody has tried to change the drag move of a RPG map to a scroll move, or know how to do that?

Thanks [import]uid: 40628 topic_id: 9708 reply_id: 309708[/import]

Do you mean to drag the map around by touch? If so, try this:

  
local onTouch = function( event )  
 map:drag( event )  
end  
  
Runtime:addEventListener( "touch", onTouch )  
  

Or are you after something else? [import]uid: 5833 topic_id: 9708 reply_id: 35357[/import]

Hi Grahan,

Thanks the quick answer, but what I want is to change this “map:drag(event) " movement, by using the scrollView.lua library of Corona, which have the " stopping delayed” effect. [import]uid: 40628 topic_id: 9708 reply_id: 35362[/import]

you must try to change the part of the code responsible for moving the map, so instead of following your finger, it moves in a direction relative to the starting point (when you clicked) [import]uid: 44010 topic_id: 9708 reply_id: 35364[/import]

I tried to put a lime map in the scrollView sample

display.setStatusBar( display.HiddenStatusBar )   
  
--import the scrolling classes  
local scrollView = require("scrollView")  
  
-- Setup a scrollable content group  
local topBoundary = display.screenOriginY  
local bottomBoundary = display.screenOriginY  
local scrollView = scrollView.new{ top=topBoundary, bottom=bottomBoundary }  
  
system.activate( "multitouch" )  
local lime = require("lime")  
  
local map = lime.loadMap("tutorial16.tmx")  
  
local player = nil  
  
local onPlayerCreate = function(property, type, object)  
 player = object  
end  
  
map:addPropertyListener("IsPlayer", onPlayerCreate)  
  
lime.createVisual(map)  
lime.buildPhysical(map)  
scrollView:insert(map)  
  
-- Important! Add a background to the scroll view for a proper hit area  
local scrollBackground = display.newRect(0, 0, display.contentWidth, scrollView.height+64)  
scrollBackground:setFillColor(255, 255, 255)  
scrollView:insert(1, scrollBackground)  
  
scrollView:addScrollBar()  
  
map:setFocus(player.sprite)  
  
local onUpdate = function(event)  
 map:update(event)  
end  
Runtime:addEventListener("enterFrame", onUpdate)  

But do not worked, returned the following error

[text]
Runtime error
…FLS2h8NzvqZWX++++TI/-Tmp-/TemporaryItems/46/main.lua:42: bad argument #-2 to ‘insert’ (Proxy expected, got nil)
stack traceback:
[C]: ?
[C]: in function ‘insert’
…FLS2h8NzvqZWX++++TI/-Tmp-/TemporaryItems/46/main.lua:42: in main chunk
Runtime error: …FLS2h8NzvqZWX++++TI/-Tmp-/TemporaryItems/46/main.lua:42: bad argument #-2 to ‘insert’ (Proxy expected, got nil)
stack traceback:
[C]: ?
[C]: in function ‘insert’
…FLS2h8NzvqZWX++++TI/-Tmp-/TemporaryItems/46/main.lua:42: in main chunk
[/text]

And my programming skills, especially in this new, to me, LUA language, are not so good enough. [import]uid: 40628 topic_id: 9708 reply_id: 35369[/import]

I’m replying on my phone so sorry for the short reply, try inserting map.world rather than just map. [import]uid: 5833 topic_id: 9708 reply_id: 35374[/import]

Hey Graham, is working now, let me try to insert the map I wanna.
Thanks again, this is a great support to your costumer, see you in the next doubt. [import]uid: 40628 topic_id: 9708 reply_id: 35381[/import]

No worries, very happy to help. [import]uid: 5833 topic_id: 9708 reply_id: 35397[/import]