我是Coronoa和Lua的新手,我正在试图弄清楚如何关闭地图和文本框.地图和文本框出现在主屏幕上,我能够创建一个按钮(只是一个类型的黑色x)并使其关闭,但我无法关闭地图或文本框.下面是我正在使用的代码片段,但我被卡住了.我搜索了Google,并阅读了他们的文档,我只是遗漏了一些东西.
local obj = display.newImageRect( "closeButton.jpg" ,25,25 )
obj.x = 60
obj.y = 410 -- replaced with newImageRect for dynamic scaling (adjust X & Y as required)
obj.touch = function (event)
local btn = event.target
if event.phase == "ended" then
btn.alpha = 0 -- example to show the function doing something
myMap.alpha = 0
textBox.alpha = 0
end
end
-- begin detecting touches
obj:addEventListener( "touch", obj.touch)
myMap = native.newMapView( 25, 0, 275, 180 )
myMap.mapType = "hybrid" -- other mapType …Run Code Online (Sandbox Code Playgroud)