How can I create Game Over

Hi

I create my first game with Corona.

I have this question:

When my points match value 3 I would like that on my Screen I get printed :

  1. Label GameOver

  2. The Button for Try Again (What api should use I? )

Is there a example?
Thanks

[import]uid: 100428 topic_id: 20541 reply_id: 320541[/import]

There isn’t a single API call for this. You will need a display.newText() object to show the Game Over label. You will need a display.newImageRect() to show a graphic, to which you attach and “Event Listener” to that will handle the tap request. Then you will need a function that restart the game when you tap the button.

Something like this:

  
local gameOverLabel = display.newText("Game Over!", display.contentWidth / 2, 100, "Helvetica", 32)  
-- that creates a string on the screen, centered left to right and 100 pixels down from the top using Helvetica as the font at 32 pixels high.  
  
local retryButton = display.newImageRect("buttongraphic.png", 128, 48)  
-- creates a graphic on screen using buttongraphic.png that is 128 pixels wide, 48 pixels high.  
-- of course you would substitute your image name and size here.  
retryButton.x = display.contentWidth / 2  
retryButton.y = 200  
-- center it horizontally, 200 pixels down  
  
local function retryGame(event)  
 -- your code to retry the level/game whatever  
 -- goes here.  
end  
  
retryButton:addEventListener("tap", retryGame)  
  

If you’re using Storyboard those will also need to be inserted into groups:

  
group:insert(gameOverLabel)  
group:insert(retryButton)  
  

or if you’re using Director:

  
localGroup:insert(gameOverLabel)  
localGroup:insert(retryButton)  
  

[import]uid: 19626 topic_id: 20541 reply_id: 80620[/import]

Thanks you

But I have not idea for this point:

– your code to retry the level/game whatever
– goes here.
I’m using objcet physics.
I start my code so:

local physics = require(“physics”)
physics.start()
physics.setScale( 60 )
display.setStatusBar( display.HiddenStatusBar )
physics.setGravity(0.0, 15.8)

–img PUFFO
local background = display.newImage( “i-puffi.jpg” )
local puffo = display.newImage( “puffo.png” )
puffo.nome = “PUFFO”
physics.addBody(puffo, { bounce =0.5 } )
physics.addBody( puffo, redBody )

– Set up score displays
local redTotal = 0
redScore = display.newText( "RIMBALZI - " … redTotal, 50, 40, native.systemFontBold, 28 )
redScore:setTextColor( 255, 255, 255)


local function onGlobalCollision( event )
if ( event.phase == “began” ) then
redTotal = redTotal + 1
updateRimbalzi()
end

How I can create GAMEOVER when redTotal=10 ?
How I stop my app?

Thnks
[import]uid: 100428 topic_id: 20541 reply_id: 80630[/import]