drag but not touch?

Currently, when I use this function to drag an object around, I can also tap anywhere on the screen and the object transports to that location.

function moveHero( event ) hero.x = event.x hero.y = event.y end Runtime:addEventListener("touch", moveHero)

Is it possible to make it so that it can only be dragged from where it currently is? [import]uid: 7116 topic_id: 6107 reply_id: 306107[/import]

Yes it’s possible.

What your code is doing is added a global event handler to touch. That means any place you touch on the screen will trigger your “moveHero” function, which is why you are seeing the object move to where ever you tap.

Runtime:addEventListener("touch", moveHero)  

Unless you have a reason to use the global handler, you will probably be better served by adding an eventlistener to your hero object instead.

hero:addEventListener("touch",moveHero)  

You may need to use a global handler but from the code you posted, and the description of your problem, it doesn’t seem like you do.

[import]uid: 22457 topic_id: 6107 reply_id: 20907[/import]