[Resolved] Remove object and display an alert at the same time?

How can I do this ?
I’ve tried with this code, but it doesn’t run ( the ball continues to collide with the object, a basket, but it doesn’t remove), it displays only the alert.

[code]
shape1={ 32.5,-32 ,27.5 ,32, 23.5, 28, 26.5, -32 }
shape2={ -20.5, 28, -26.5, 32, -30.5, -32, -24.5, -32}
shape3={ -20.5, 28, 23.5, 28, 27.5, 32, -26.5, 32 }

local flag=display.newImage(“basket.png”)
flag.x=display.contentWidth-100
flag.y=display.contentHeight-90
flag.rotation= -60
physics.addBody( flag, “static”, { shape=shape1}, {shape=shape2}, {shape=shape3})
localGroup:insert(flag)

local function onBounce ( self, event )
ball:removeSelf()
media.playEventSound(“Pop.aiff”)
end
flag.collision = onBounce
flag:addEventListener(“collision”, onBounce)

– Alert

local function onComplete( event )
if “clicked” == event.action then
local i = event.index
if 1 == i then
director:changeScene(“level10”)
end
end
end

–collision
local function hitGround (event)

native.showAlert( “Congratulations!!!”, “Go to the next level”, { “Next Level” }, onComplete )

end

end
flag:addEventListener(“collision”, hitGround)
[/code] [import]uid: 27760 topic_id: 30404 reply_id: 330404[/import]

I can’t see where your call is created from the above code - if it’s below line 12 you will likely have some issues there.

Also you have two “ends” in the hitGround function when you should only have one; this should be throwing you an error in the terminal, something like " expected near end". [import]uid: 52491 topic_id: 30404 reply_id: 121959[/import]

I’ve corrected the “end” issue, but what are the issues in line 12? [import]uid: 27760 topic_id: 30404 reply_id: 121973[/import]

No problem, I’ve solved my problem! Thank you [import]uid: 27760 topic_id: 30404 reply_id: 121983[/import]

Oh great, thanks for updating. Marking as resolved :slight_smile: [import]uid: 52491 topic_id: 30404 reply_id: 122094[/import]

I can’t see where your call is created from the above code - if it’s below line 12 you will likely have some issues there.

Also you have two “ends” in the hitGround function when you should only have one; this should be throwing you an error in the terminal, something like " expected near end". [import]uid: 52491 topic_id: 30404 reply_id: 121959[/import]

I’ve corrected the “end” issue, but what are the issues in line 12? [import]uid: 27760 topic_id: 30404 reply_id: 121973[/import]

No problem, I’ve solved my problem! Thank you [import]uid: 27760 topic_id: 30404 reply_id: 121983[/import]

Oh great, thanks for updating. Marking as resolved :slight_smile: [import]uid: 52491 topic_id: 30404 reply_id: 122094[/import]