[Resolved] How can I show an alert on collision??

I’ve been trying to do it it for ages, but I’m not able. [import]uid: 27760 topic_id: 25473 reply_id: 325473[/import]

Hey Marco,

Run this code on its own, the alert is the one from the API pages;

[lua]–Hide the status bar
display.setStatusBar(display.HiddenStatusBar)

– Set up physics
require ( “physics” )
physics.start()
physics.setGravity( 0, 9 )

–Show a block
local block = display.newRect( 120, 50, 80, 80 )
physics.addBody(block, {bounce=0})

–Put in a static ground
local ground = display.newRect( 0, 460, 320, 20 )
physics.addBody(ground, “static”, {bounce=0})

–Alert onComplete function
local function onComplete( event )
if “clicked” == event.action then
local i = event.index
if 1 == i then
– Do nothing; dialog will simply dismiss
elseif 2 == i then
– Open URL if “Learn More” (the 2nd button) was clicked
system.openURL( “http://developer.anscamobile.com” )
end
end
end

–Collision function
local function hitGround (event)
if event.phase == “began” then
–Show alert
local alert = native.showAlert( “Corona”, “Dream. Build. Ship.”, { “OK”, “Learn More” }, onComplete )
end
end
ground:addEventListener(“collision”, hitGround)[/lua]

Peach :slight_smile: [import]uid: 52491 topic_id: 25473 reply_id: 103049[/import]

Thank you very much Peach, I’m new here and I’m just 14. [import]uid: 27760 topic_id: 25473 reply_id: 103111[/import]

No worries.

You will find a few teenagers about your age around the forum, we have a great mix of age groups here :slight_smile:

Peach [import]uid: 52491 topic_id: 25473 reply_id: 103244[/import]

Yes I know. For example Robert Nay… he has helped me a lot. [import]uid: 27760 topic_id: 25473 reply_id: 103319[/import]

Great to hear, he’s a nice guy - helped with judging the Techority 48 Hour challenge this year :slight_smile: [import]uid: 52491 topic_id: 25473 reply_id: 103471[/import]