http://dl.dropbox.com/u/29886031/Shield.zip
[lua]local stage
local stageEventShield
local topGroup = display.newGroup();
local function setUpShield()
stage = {
x = 0,
y = 0,
width = display.contentWidth,
height = display.contentHeight
}
stage.left = stage.x
stage.right = stage.x + stage.width
stage.top = stage.y
stage.bottom = stage.y + stage.height
– Create stage event shield
stageEventShield = display.newRect(topGroup,
stage.x, stage.y,
stage.width, stage.height)
stageEventShield.isVisible = false
stageEventShield:setFillColor(255, 255, 255, 128)
– Block all events
stageEventShield:addEventListener(“touch”, function(event)
if event.phase == “ended” then
stageEventShield.isVisible = false
stageEventShield:toBack()
end
return true
end)
end
setUpShield()
Runtime:addEventListener(“orientation”, function(event)
setUpShield()
end)
local background = display.newImageRect(“portrait.png”, 320, 480)
local function raiseShield(event)
if event.phase == “ended” then
stageEventShield.isVisible = true
stageEventShield:toFront()
end
end
background:addEventListener(“touch”, raiseShield)
topGroup:insert(background)
background.x = display.contentWidth / 2
background.y = display.contentHeight / 2[/lua]
Very very simple code, right?
Click once, the shield overlay comes up. Click on the shield overlay, the shield overlay is removed from view.
Now, change orientation to landscape and do the same test.
Notice that the shield overlay doesn’t cover the whole screen.
Why? [import]uid: 59054 topic_id: 10389 reply_id: 310389[/import]
