Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

How do I determine the coordinates on the "map of the world" which happened tap
Started by eto_ru Nov 03 2018 11:57 PM

2 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

eto_ru

[GLOBAL: userInfoPane.html]
eto_ru
  • Observer

  • 17 posts
  • Corona SDK

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



[TOPIC: post.html]
#2

eto_ru

[GLOBAL: userInfoPane.html]
eto_ru
  • Observer

  • 17 posts
  • Corona SDK

resolved



[TOPIC: post.html]
#3

eto_ru

[GLOBAL: userInfoPane.html]
eto_ru
  • Observer

  • 17 posts
  • Corona SDK

function mapsGroupTap (event)
    if ( event.numTaps == 2 ) then
    display.newRect( mapsGroup, event.x - mapsGroup.x, event.y - mapsGroup.y, 10, 10 ):setFillColor(0)

    print( "Object double-tapped: " .. tostring((mapsGroup.x + event.x)) .. " - " .. tostring((mapsGroup.y + event.y)) )
    end
end




[topic_controls]
[/topic_controls]