local mapsGroup = display.newGroup() mapsGroup.x = \_CX mapsGroup.y = \_CY local background = display.newImageRect( "maps.png" 1536, 675) mapsGroup:insert( background ) function mapsGroupListener ( event ) if event.phase == "began" then mapsGroup.markX = mapsGroup.x mapsGroup.markY = mapsGroup.y elseif event.phase == "moved" then local x = (event.x - event.xStart) + mapsGroup.markX local y = (event.y - event.yStart) + mapsGroup.markY mapsGroup.x = x mapsGroup.y = y if mapsGroup.x \> mapsGroup.width / 2 then mapsGroup.x = mapsGroup.width / 2 end if mapsGroup.x \< \_CW - (mapsGroup.width / 2) then mapsGroup.x = \_CW - (mapsGroup.width / 2) end if mapsGroup.y \> \_CH - (mapsGroup.height - \_CH) then mapsGroup.y = \_CH - (mapsGroup.height - \_CH) end if mapsGroup.y \< mapsGroup.height - \_CH then mapsGroup.y = mapsGroup.height - \_CH end print ("x " .. mapsGroup.x .. " " .. mapsGroup.y) end return true end function mapsGroupTap (event) if ( event.numTaps == 2 ) then display.newRect( mapsGroup, mapsGroup.x, mapsGroup.y, 10, 10 ):setFillColor(0) print( "Object double-tapped: " .. tostring((mapsGroup.x + event.x)) .. " - " .. tostring((mapsGroup.y + event.y)) ) end end mapsGroup:addEventListener( "tap", mapsGroupTap ) mapsGroup:addEventListener( "touch", mapsGroupListener)
the mapsGroupTap function must create an object and set its coordinates on the map,
please help