Hi I am having a problem in my navigation displayed in the top corner of my app. I created a button. When it is pressed I would like to show an overlay with the menu in it with serverak gotoScenes. If it is pressed Again I want to hide it.
This is what the code looks like for my navigation
local storyboard = require “storyboard”
local widget = require “widget”
local w = display.contentWidth
local h = display.contentHeight
local navigation_group = display.newGroup()
–function for press positioning
local function ptInside(obj, x, y)
local inside = false
local objx = obj.x - (obj.width / 2)
local objy = obj.y - (obj.height / 2)
if (x >= objx) and
(x <= (objx + obj.width)) and
(y >= objy) and
(y <= (objy + obj.height)) then
inside = true
end
return inside
end
—show navigation background
local header = display.newImageRect(“images/header.png”, w, 36);
header:setReferencePoint( display.CenterLeftReferencePoint )
header.x = 0
header.y = 18
navigation_group:insert(header)
–menu button
local menuclosed = true
local menuBtn = display.newGroup()
menuBtn:insert( display.newImage( “images/menu_closed.png”, true ) )
menuBtn:insert( display.newImage( “images/menu_open.png”, true ) )
menuBtn[2].isVisible = false
menuBtn.active = false
menuBtn.x = 267
menuBtn.y = 18
for i=1,menuBtn.numChildren do
local child = menuBtn[i]
local description = (child.isVisible and “visible”) or “not visible”
print( “child[”…i…"] is " … description )
end
– remove the old image, put in the new image
local function onMenuBtn( event )
local t = event.target
print(event.phase)
if event.phase == “began” then
t.active = true
display.getCurrentStage():setFocus(t)
else
display.getCurrentStage():setFocus(nil)
end
if event.phase == “ended” and t.active then
t.active = false
if ptInside(t, event.x, event.y) then
if (menuclosed ) then
menuclosed = false
menuBtn[1].isVisible = false
menuBtn[2].isVisible = true
storyboard.showOverlay( “menu”, “fromTop”, 400)
else
menuclosed = true
menuBtn[1].isVisible = true
menuBtn[2].isVisible = false
storyboard.hideOverlay(“menu”, “slideUp”, 400)
end
end
end
For some reason the overlay is not hidden on every click. Sometimes it just seems to ignore the line of code storyboard.hideOverlay(“menu”, “slideUp”, 400). What should I do to prevent this from happening? [import]uid: 191606 topic_id: 34787 reply_id: 334787[/import]