How to display buttons after enterframe event is over in Corona?

Posted by user1463542 on Stack Overflow See other posts from Stack Overflow or by user1463542
Published on 2012-06-18T21:14:22Z Indexed on 2012/06/18 21:15 UTC
Read the original article Hit count: 193

Filed under:
|
|
|

I am trying to display two buttons called countd_again and main_menu after my enterframe event is over. I can't see those buttons after enterframe event is over,though. Can you check my code,please? And also i want to add new addListener for the buttons using director and scene.

module(..., package.seeall)

function new()

local localGroup = display.newGroup();

display.setStatusBar(display.HiddenStatusBar)
local background = display.newImage("background.png")
start=os.time()
cnt=1

local countd_again = display.newImage("yeniden.png")
countd_again.x=100
countd_again.y=100
countd_again.isVisible= false;
countd_again.alpha=0;
countd_again.scene="helloWorld";

local main_menu= display.newImage("anamenu.png")
main_menu.x=100
main_menu.y=300
main_menu.isVisible=false;
main_menu.alpha=0;
main_menu.scene="helloWorld"

 -- listener function
 local function onEveryFrame( event )


 if (cnt~=0) then
     cnt= 3-(os.time()-start)
       minute = math.floor(cnt/60)
       second=cnt%60

       --print(minute,second)
        minTxt=display.newText(minute,50,50,nil,100)
        secTxt=display.newText(second,250,50,nil,100)
         transition.to(minTxt,  {time=100, alpha=0})
         transition.to(secTxt,{time=100, alpha=0})
    else
     Runtime: removeEventListener("enterFrame",onEveryFrame)

    countd_again.isVisible=true;
    main_menu.isVisible=true;
    transition.to(countd_again,{time=500,alpha=1});
    transition.to(main_menu,{time=500,alpha=1});
    countd_again: addEventListener("touch", changeScene)
     main_menu: addEventListener("touch", changeScene) 

end

end

-- assign the above function as an "enterFrame" listener
Runtime:addEventListener( "enterFrame", onEveryFrame )

function changeScene(e)
  if(e.phase=="ended") then
  director:changeScene(e.target.scene);
  end
end

countd_again: addEventListener("touch", changeScene)
main_menu: addEventListener("touch", changeScene) 

localGroup: insert(countd_again)
localGroup:insert(main_menu)
localGroup:insert(background)



return localGroup;

end

© Stack Overflow or respective owner

Related posts about lua

Related posts about corona