function new(func)
local obj = display.newGroup()
Scene.decorate(obj) – Control Transitions
function scene:createScene( event )
group = self.view
--define button dimensions
local btnW, btnH = 100, 20
--create pause button
obj.pauseBtn = display.newImageRect( “button.png”, btnW, btnH )
--place button in center
obj.pasueBtn.anchorX = 0.5
obj.pauseBtn.anchorY = 0.5
obj.pauseBtn.x, obj.pauseBtn.y = display.contentWidth-(btnW/2), display.contentHeight-(btnH/2)
--add event
obj.pauseBtn:addEventListener( “touch”, pauseGame )
group:insert( obj.pauseBtn )
--create resume button
obj.resumeBtn = display.newImageRect( “blockBlue1.png”, btnW, btnH )
--put it on pause button
obj.resumeBtn.anchorX = 0.5
obj.resumeBtn.anchorY = 0.5
obj.resumeBtn.x, obj.resumeBtn.y = display.contentWidth-(btnW/2), display.contentHeight-(btnH/2)
--and hide it
obj.resumeBtn.isVisible = false
--add event
obj.resumeBtn:addEventListener( “touch”, resumeGame )
group:insert( obj.resumeBtn )
end
–pause game
function pauseGame(event)
--if end of touch event
if(event.phase == “ended”) then
--pause the physics
physics.pause()
--make pause button invisible
obj.pauseBtn.isVisible = false
--make resume button visible
obj.resumeBtn.isVisible = true
– indicates successful touch
return true
end
end
–resume game
function resumeGame(event)
--if end of touch event
if(event.phase == “ended”) then
--resume physics
physics.start()
--make pause button visible
obj.pauseBtn.isVisible = true
--make resume button invisible
obj.resumeBtn.isVisible = false
– indicates successful touch
return true
end
end
This is the code so far, but the problem is that when i start it, the buttons don’t show up so i can’t test if the code works. To add to this, there are no errors at all, so i’m having trouble identifying why it’s not working.