tenth,
Please see this video: http://www.youtube.com/watch?v=Hj6UfzyxALM
Is this what you’re thinking about making? If so, it is pretty easy to do.
I made this sample as follows:
- Create display group:
local theDrawer = display.newGroup()
- Add background, buttons, etc. to the new group (warning this code is from SSK a free project I’m currently putting together for the Corona community; but I think you’ll get the idea.):
local trayImage = display.newImageRect( theDrawer, imagesDir .. "felt.png", 110,
screenHeight)
trayImage.alpha = 0.3
trayImage.x = 55
trayImage.y = centerY
buttons:presetPush( theDrawer, "blueButton", screenLeft+100, centerY,
20, screenHeight, "", onDrawerButton )
tmpButton.alpha = 0.25
buttons:presetPush( theDrawer, "yellowButton", screenLeft+45, 50,
60, 60, "A", onDrawerButton, {textSize = 36 } )
buttons:presetPush( theDrawer, "orangeButton", screenLeft+45, 120,
60, 60, "B", onDrawerButton, {textSize = 36 } )
buttons:presetPush( theDrawer, "redButton", screenLeft+45, 190,
60, 60, "C", onDrawerButton, {textSize = 36 } )
- Start the tray in the ‘slid off the screen position’
theDrawer.x = -90
theDrawer.isOpen = false
- Later, when a button is pressed, transition the tray on or off the screen:
onDrawerButton = function ( event )
if(event.phase ~= "ended") then return false end
if(theDrawer.isOpen) then
transition.to( theDrawer, {x = -90, time = 200} )
theDrawer.isOpen = false
else
transition.to( theDrawer, {x = 0, time = 200} )
theDrawer.isOpen = true
end
return true
end
Please note: There are many ways to detect the need for a transition, but you did mention button presses so I used that as my sample.
I hope this helps. [import]uid: 110228 topic_id: 29853 reply_id: 119992[/import]