O'Reilly logo

Corona SDK Application Design by Daniel Williams

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Dragging-and-dropping display objects

Now we are going to set up the core functionality for our app—dragging-and-dropping display objects. To allow our players to drag-and-drop display objects, we have to set up a function that will allow them to grab an object and drag it around the screen. We can accomplish this by attaching an event listener to the object with the function that handles the dragging. However, before we can attach the event listener, we need to set up a function dedicated to this purpose.

A sample drag function with the associated object event listener would be as follows:

local function onDrag(event) local t = event.target if event.phase == "began" then elseif t.isFocus then if "moved" == event.phase then elseif "ended" == event.phase ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required