Firs of all i want to thank community for so much help. Thank you all.
I have a simple problem. When level complete i have have a popup image then i add buttons to it such as, next level, replay, and menu. Now i want all thing to be deleted when i press any of the buttons.
Here is the code i have written:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | ----------------------------------------------------------------------------------- -- Pop Up manu handlers when level is done and complete ----------------------------------------------------------------------------------- -- Replay pressed local function replayPressed(b) game.playEventSound(game.soundPressed) game.changeScene("level1","overFromTop") end -- Menu Pressed local function menuPressed(b) game.playEventSound(game.soundPressed) game.changeScene("mainscene","overFromTop") game.popUp = false end ----------------------------------------------------------------------------------- --Button press handlers goes here ----------------------------------------------------------------------------------- -- When shapes colided with rope then do this local function showmsg() game.popUp = true levelOver = display.newImageRect("levels/PopupLevelComplete.png", 338, 155) levelOver.x = 240 levelOver.y = -100 transition.to(levelOver,{time = 100, x = 240 , y = 160 }) group:insert(levelOver) -- Add buttons here replayButton=button:create(group,1,{x= - 200,y=190,w=155,h=65,handler=replayPressed}, "levels/ReplayLevel.png") transition.to(replayButton,{time = 1000, x = 155 , y = 190 }) -- Add Menu button menuButton=button:create(group,1,{x= 240,y= - 200,w=138,h=55,handler=menuPressed}, "levels/Menu.png") transition.to(menuButton,{time = 1000, x = 240 , y = 130 }) -- Add next button nextButton=button:create(group,1,{x=600,y=190,w=155,h=65,handler=nextPressed}, "levels/NextLevel.png") transition.to(nextButton,{time = 1000, x = 320 , y = 190 }) end local function onCollision (event ) if game.popUp then return end if event.phase == "began" and event.other.name == "shape" then timer.performWithDelay (1000, showmsg) end end |
Something like this may help you;
1 2 3 4 | popupGroup = display.newGroup() popupGroup:insert(replayButton) popupGroup:insert(menuButton) popupGroup:insert(nextButton) |
views:1471 update:2012/1/15 11:04:51