I threw togeather a plug and play code for you showing my way of doing it.
local widget = require "widget"
local popupGroup = display.newGroup()
local showPopup
local hide = function (event )
if event.phase == "release" then
transition.to(popupGroup,{time = 500, alpha = 0 })
showPopup.alpha = 1
end
return true
end
local show = function (event )
if event.phase == "release" then
transition.to(popupGroup,{time = 500, alpha = 1 })
showPopup.alpha = 0
end
return true
end
local hideBtn = widget.newButton{
id = "btn001",
label = "Hide Popup",
width = 150, height = 28,
cornerRadius = 8,
onEvent = hide
}
local popupWindow = display.newRect(popupGroup, 0, 0, 250, 150)
popupWindow.strokeWidth = 3
popupWindow:setFillColor(0, 250, 250)
popupWindow:setStrokeColor(255)
popupWindow.x = display.contentWidth/2
popupWindow.y = display.contentHeight/2
popupGroup:insert( hideBtn )
hideBtn.x = popupWindow.x
hideBtn.y = popupWindow.y
popupGroup.alpha = 0
showPopup = widget.newButton{
id = "btn001",
label = "showPopup",
width = 150, height = 28,
cornerRadius = 8,
onEvent = show
}
showPopup.x = display.contentWidth/2
showPopup.y = display.contentHeight/2
Ofcourse there is easier ways of doing this, but i thought this would be the easiest to understand.
[import]uid: 134049 topic_id: 35229 reply_id: 140048[/import]